Class: ShelbyArena::Client

Inherits:
Object
  • Object
show all
Includes:
Batch, Contribution, Fund, Person
Defined in:
lib/shelby_arena/client.rb,
lib/shelby_arena/resources/fund.rb,
lib/shelby_arena/resources/batch.rb,
lib/shelby_arena/resources/person.rb,
lib/shelby_arena/resources/contribution.rb

Defined Under Namespace

Modules: Batch, Contribution, Fund, Person

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Contribution

#create_contribution, #find_contribution, #find_contributions_by_batch_id, #list_contributions

Methods included from Person

#create_person, #find_people_by_email, #find_people_by_name_and_email, #find_person, #list_people, #update_person

Methods included from Fund

#find_fund, #list_funds

Methods included from Batch

#create_batch, #delete_batch, #find_batch, #list_batches

Constructor Details

#initialize(url:, username:, password:, api_key:, api_secret:, logger: true, adapter: Faraday.default_adapter, ssl: nil) ⇒ Client

Returns a new instance of Client.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/shelby_arena/client.rb', line 16

def initialize(url:, username:, password:, api_key:, api_secret:, logger: true, adapter: Faraday.default_adapter, ssl: nil)
  if username.nil? && password.nil?
    raise ArgumentError, 'either username and password'
  end

  @url      = "#{url}/api.svc/"
  @username = username
  @password = password
  @api_key  = api_key
  @api_secret  = api_secret
  @logger   = logger
  @adapter  = adapter
  @ssl      = ssl
  @api_session = fetch_api_session
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



14
15
16
# File 'lib/shelby_arena/client.rb', line 14

def adapter
  @adapter
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



14
15
16
# File 'lib/shelby_arena/client.rb', line 14

def api_key
  @api_key
end

#api_secretObject (readonly)

Returns the value of attribute api_secret.



14
15
16
# File 'lib/shelby_arena/client.rb', line 14

def api_secret
  @api_secret
end

#api_sessionObject (readonly)

Returns the value of attribute api_session.



14
15
16
# File 'lib/shelby_arena/client.rb', line 14

def api_session
  @api_session
end

#loggerObject (readonly)

Returns the value of attribute logger.



14
15
16
# File 'lib/shelby_arena/client.rb', line 14

def logger
  @logger
end

#passwordObject (readonly)

Returns the value of attribute password.



14
15
16
# File 'lib/shelby_arena/client.rb', line 14

def password
  @password
end

#sslObject (readonly)

Returns the value of attribute ssl.



14
15
16
# File 'lib/shelby_arena/client.rb', line 14

def ssl
  @ssl
end

#urlObject (readonly)

Returns the value of attribute url.



14
15
16
# File 'lib/shelby_arena/client.rb', line 14

def url
  @url
end

#usernameObject (readonly)

Returns the value of attribute username.



14
15
16
# File 'lib/shelby_arena/client.rb', line 14

def username
  @username
end

Instance Method Details

#delete(path, options = {}) ⇒ Object



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

def delete(path, options = {})
  connection.delete(path, options).body
end

#get(path, options = {}) ⇒ Object



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

def get(path, options = {})
  connection.get(path, options).body
end

#json_post(path, options = {}) ⇒ Object



48
49
50
# File 'lib/shelby_arena/client.rb', line 48

def json_post(path, options = {})
  connection(true).post(path, options).body
end

#patch(path, options = {}) ⇒ Object



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

def patch(path, options = {})
  connection.patch(path, options).body
end

#post(path, options = {}) ⇒ Object



44
45
46
# File 'lib/shelby_arena/client.rb', line 44

def post(path, options = {})
  connection.post(path, options).body
end

#put(path, options = {}) ⇒ Object



52
53
54
# File 'lib/shelby_arena/client.rb', line 52

def put(path, options = {})
  connection.put(path, options).body
end