class Codingapi::Codinginterface

Your code goes here…

Attributes

token[RW]

Gets or sets the path that the Faraday libs are loaded from. @return [String]

username[RW]

Public Class Methods

new(username: nil, token: nil) click to toggle source
# File lib/codingapi/codinginterface.rb, line 18
def initialize(username: nil, token: nil)
    @username = username
    @token = token

    puts "username = #{@username}"
    puts "token = #{@token}"
    return self
end

Public Instance Methods

get_all_project(page: 0, page_szie: 10) click to toggle source
puts "username = #{@username}"
puts "token = #{@token}"

end

# File lib/codingapi/codinginterface.rb, line 35
def get_all_project(page: 0, page_szie: 10)
    
    # curl -H "Authorization: token 1f5eb8c4ac157b21d54e85e04e688433e8c8a495" https://coding.net/api/user/projects?page=3

    base_url = "https://coding.net"
    con = Faraday.new
    url = base_url + "/api/user/projects"
  
    puts url + "?page=#{page} && pageSize=#{page_szie}" 

    res = con.get do |req|
        req.url url
        req.headers['Content-Type'] = 'application/json;charset=UTF-8'
        req.headers['Authorization'] = "token " + self.token
        req.params['type'] = "all"
        req.params['page'] = "#{page}"
        req.params['pageSize'] = "#{page_szie}"
    end
     
    puts res.body
    response = JSON.parse(res.body)
 
    return response

end