Class: Gitea::Client
- Inherits:
-
Object
- Object
- Gitea::Client
- Defined in:
- lib/gitea/client.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
BASE_URL = “api.buildkite.com/v2”.
-
#adapter ⇒ Object
readonly
BASE_URL = “api.buildkite.com/v2”.
-
#url ⇒ Object
readonly
BASE_URL = “api.buildkite.com/v2”.
Instance Method Summary collapse
- #commit_statuses ⇒ Object
- #connection ⇒ Object
-
#initialize(url:, access_token:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
- #org_hooks ⇒ Object
- #orgs ⇒ Object
- #repo_hooks ⇒ Object
- #repos ⇒ Object
- #user ⇒ Object
- #user_repos ⇒ Object
Constructor Details
#initialize(url:, access_token:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 |
# File 'lib/gitea/client.rb', line 7 def initialize(url:, access_token:, adapter: Faraday.default_adapter, stubs: nil) @url = url @access_token = access_token @adapter = adapter # Test stubs for requests @stubs = stubs end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
BASE_URL = “api.buildkite.com/v2”
5 6 7 |
# File 'lib/gitea/client.rb', line 5 def access_token @access_token end |
#adapter ⇒ Object (readonly)
BASE_URL = “api.buildkite.com/v2”
5 6 7 |
# File 'lib/gitea/client.rb', line 5 def adapter @adapter end |
#url ⇒ Object (readonly)
BASE_URL = “api.buildkite.com/v2”
5 6 7 |
# File 'lib/gitea/client.rb', line 5 def url @url end |
Instance Method Details
#commit_statuses ⇒ Object
40 41 42 |
# File 'lib/gitea/client.rb', line 40 def commit_statuses CommitStatusesResource.new(self) end |
#connection ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/gitea/client.rb', line 44 def connection full_url = [url, "api/v1"].join("/") @connection ||= Faraday.new(full_url) do |conn| conn.request :authorization, :token, access_token conn.headers = { "User-Agent" => "gitearb/v#{VERSION} (github.com/deanpcmad/gitearb)" } conn.request :json conn.response :json, content_type: "application/json" conn.adapter adapter, @stubs end end |
#org_hooks ⇒ Object
28 29 30 |
# File 'lib/gitea/client.rb', line 28 def org_hooks OrgHooksResource.new(self) end |
#orgs ⇒ Object
24 25 26 |
# File 'lib/gitea/client.rb', line 24 def orgs OrgsResource.new(self) end |
#repo_hooks ⇒ Object
36 37 38 |
# File 'lib/gitea/client.rb', line 36 def repo_hooks RepoHooksResource.new(self) end |
#repos ⇒ Object
32 33 34 |
# File 'lib/gitea/client.rb', line 32 def repos ReposResource.new(self) end |
#user ⇒ Object
16 17 18 |
# File 'lib/gitea/client.rb', line 16 def user UserResource.new(self) end |
#user_repos ⇒ Object
20 21 22 |
# File 'lib/gitea/client.rb', line 20 def user_repos UserReposResource.new(self) end |