Class: Eventbrite::Api::Client

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/eventbrite/api/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#model

Constructor Details

#initialize(options) ⇒ Client



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/eventbrite/api/client.rb', line 11

def initialize(options)
  model :User
  model :Venue
  model :Organizer
  model :Order
  model :Event
  model :Category
  model :Format
  model :EventTicketClass
  model :UserContact
  model :UserContactList
  model :UserOrder
  model :UserVenue
  model :UserOrganizer
  model :OwnedEvent
  model :OwnedEventAttendee
  model :OwnedEventOrder

  @redirect_uri         = options[:redirect_uri]
  @consumer             = options[:consumer]
  @access_token         = options[:access_token]

  @client               = OAuth2::Client.new(@consumer[:key], @consumer[:secret], {
    :site          => 'https://www.eventbrite.com',
    :authorize_url => '/oauth/authorize',
    :token_url     => '/oauth/token',
  })
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



9
10
11
# File 'lib/eventbrite/api/client.rb', line 9

def access_token
  @access_token
end

#clientObject (readonly)

Returns the value of attribute client.



9
10
11
# File 'lib/eventbrite/api/client.rb', line 9

def client
  @client
end

Instance Method Details

#connectionObject



57
58
59
# File 'lib/eventbrite/api/client.rb', line 57

def connection
  @auth_connection ||= OAuth2::AccessToken.new(@client, @access_token)
end

#get_access_code_url(params = {}) ⇒ Object



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

def get_access_code_url(params = {})
  @client.auth_code.authorize_url(params.merge(redirect_uri: @redirect_uri))
end

#get_access_token(access_code) ⇒ Object



44
45
46
47
48
# File 'lib/eventbrite/api/client.rb', line 44

def get_access_token(access_code)
  @token         = @client.auth_code.get_token(access_code, redirect_uri: @redirect_uri)
  @access_token  = @token.token
  @token
end

#headersObject



50
51
52
53
54
55
# File 'lib/eventbrite/api/client.rb', line 50

def headers
  {
    'Accept'            => 'application/json',
    'Content-Type'      => 'application/json'
  }
end