Class: Gitea::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/gitea/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_tokenObject (readonly)

BASE_URL = “api.buildkite.com/v2



5
6
7
# File 'lib/gitea/client.rb', line 5

def access_token
  @access_token
end

#adapterObject (readonly)

BASE_URL = “api.buildkite.com/v2



5
6
7
# File 'lib/gitea/client.rb', line 5

def adapter
  @adapter
end

#urlObject (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_statusesObject



40
41
42
# File 'lib/gitea/client.rb', line 40

def commit_statuses
  CommitStatusesResource.new(self)
end

#connectionObject



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_hooksObject



28
29
30
# File 'lib/gitea/client.rb', line 28

def org_hooks
  OrgHooksResource.new(self)
end

#orgsObject



24
25
26
# File 'lib/gitea/client.rb', line 24

def orgs
  OrgsResource.new(self)
end

#repo_hooksObject



36
37
38
# File 'lib/gitea/client.rb', line 36

def repo_hooks
  RepoHooksResource.new(self)
end

#reposObject



32
33
34
# File 'lib/gitea/client.rb', line 32

def repos
  ReposResource.new(self)
end

#userObject



16
17
18
# File 'lib/gitea/client.rb', line 16

def user
  UserResource.new(self)
end

#user_reposObject



20
21
22
# File 'lib/gitea/client.rb', line 20

def user_repos
  UserReposResource.new(self)
end