Class: AddonsApi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/addons-api/client.rb

Defined Under Namespace

Classes: AddonService, OAuth, Team, Wrapper

Class Method Summary collapse

Class Method Details

.connect(options = nil) ⇒ Object

Get a Client configured to use Token authentication.



10
11
12
13
# File 'lib/addons-api/client.rb', line 10

def self.connect(options=nil)
  options = sanitize_options(options)
  Wrapper.new(options)
end

.connect_with_token(token, options = nil) ⇒ Object

Get a Client configured to use Token authentication.



16
17
18
19
20
# File 'lib/addons-api/client.rb', line 16

def self.connect_with_token(token, options=nil)
  options = sanitize_options(options)
  options[:token] = token
  Wrapper.new(options)
end

.sanitize_options(options) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/addons-api/client.rb', line 22

def self.sanitize_options(options)
  return {} if options.nil?

  final_options = {}
  final_options[:auto_paginate] = options[:auto_paginate] if options[:auto_paginate]
  final_options[:headers] = options[:headers] if options[:headers]
  final_options[:timeout] = options[:timeout] if options[:timeout]
  final_options[:token] = options[:token] if options[:token]
  final_options[:base_url] = options[:base_url] if options[:base_url]
  final_options
end