Class: Pindo::GiteeClient
- Inherits:
-
Object
- Object
- Pindo::GiteeClient
- Defined in:
- lib/pindo/client/giteeclient.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
Instance Method Summary collapse
- #gitee_create_repo(owner: nil, repo_name: nil, public_type: 0) ⇒ Object
-
#initialize(access_token: nil) ⇒ GiteeClient
constructor
A new instance of GiteeClient.
Constructor Details
#initialize(access_token: nil) ⇒ GiteeClient
Returns a new instance of GiteeClient.
12 13 14 15 |
# File 'lib/pindo/client/giteeclient.rb', line 12 def initialize(access_token:nil) @base_url = "https://gitee.com" @access_token = access_token end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
10 11 12 |
# File 'lib/pindo/client/giteeclient.rb', line 10 def access_token @access_token end |
#base_url ⇒ Object
Returns the value of attribute base_url.
9 10 11 |
# File 'lib/pindo/client/giteeclient.rb', line 9 def base_url @base_url end |
Instance Method Details
#gitee_create_repo(owner: nil, repo_name: nil, public_type: 0) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/pindo/client/giteeclient.rb', line 19 def gitee_create_repo(owner:nil, repo_name:nil, public_type:0) body_params = { access_token:access_token, name:repo_name, path:repo_name, org:owner, public:public_type, # private:true, has_issues:true, has_wiki:true, auto_init:false, gitignore_template:"C", license_template:"AGPL-3.0" } puts body_params # repao_name_str = %Q{"name": "#{repo_name}",} # body_str = '{ "access_token": "' + access_token + '",' + repao_name_str + '"has_issues": true, "has_wiki": true, "private": "true", "auto_init":false, "gitignore_template":"C", "license_template":"AGPL-3.0"' + '}' body_str = body_params.to_json url = @base_url + "/api/v5/orgs/#{owner}/repos" # puts body_str con = Faraday.new res = con.post do |req| req.url url req.headers['Content-Type'] = 'application/json' req.body = body_str end # puts res.body # puts res.body if res.body['error'].nil? puts "Create success !!!" return true else puts res.body['error'] return false end end |