Class: Tiltify::Client

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

Constant Summary collapse

BASE_URL =
"https://tiltify.com/api/v3"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
13
# File 'lib/tiltify/client.rb', line 7

def initialize(access_token:, adapter: Faraday.default_adapter, stubs: nil)
  @access_token = access_token
  @adapter = adapter

  # Test stubs for requests
  @stubs = stubs
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



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

def access_token
  @access_token
end

#adapterObject (readonly)

Returns the value of attribute adapter.



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

def adapter
  @adapter
end

Instance Method Details

#campaignsObject



15
16
17
# File 'lib/tiltify/client.rb', line 15

def campaigns
  CampaignsResource.new(self)
end

#causesObject



19
20
21
# File 'lib/tiltify/client.rb', line 19

def causes
  CausesResource.new(self)
end

#connectionObject



35
36
37
38
39
40
41
42
43
# File 'lib/tiltify/client.rb', line 35

def connection
  @connection ||= Faraday.new(BASE_URL) do |conn|
    conn.request :authorization, :Bearer, access_token
    conn.request :json
    conn.response :json

    conn.adapter adapter, @stubs
  end
end

#fundraising_eventsObject



23
24
25
# File 'lib/tiltify/client.rb', line 23

def fundraising_events
  FundraisingEventsResource.new(self)
end

#teamsObject



31
32
33
# File 'lib/tiltify/client.rb', line 31

def teams
  TeamsResource.new(self)
end

#usersObject



27
28
29
# File 'lib/tiltify/client.rb', line 27

def users
  UsersResource.new(self)
end