Module: Suzuri

Defined in:
lib/suzuri_client.rb

Defined Under Namespace

Classes: Choice, Client, Favorite, Identity, Item, ItemColor, ItemSize, ItemVariant, Material, Product, Profile, User

Class Method Summary collapse

Class Method Details

.connect(api_key, options = nil) ⇒ Client

Get a Client configured to use HTTP Basic authentication.



22
23
24
25
26
27
28
29
# File 'lib/suzuri_client.rb', line 22

def self.connect(api_key, options=nil)
  options = custom_options(options)
  uri = URI.parse(options[:url])
  uri.user = options.fetch(:user, 'user').gsub('@', '%40')
  uri.password = api_key
  client = Heroics.client_from_schema(SCHEMA, uri.to_s, options)
  Client.new(client)
end

.connect_oauth(oauth_token, options = nil) ⇒ Client

Get a Client configured to use OAuth authentication.



39
40
41
42
43
44
# File 'lib/suzuri_client.rb', line 39

def self.connect_oauth(oauth_token, options=nil)
  options = custom_options(options)
  url = options[:url]
  client = Heroics.oauth_client_from_schema(oauth_token, SCHEMA, url, options)
  Client.new(client)
end

.connect_token(token, options = nil) ⇒ Client

Get a Client configured to use Token authentication.



54
55
56
57
58
59
# File 'lib/suzuri_client.rb', line 54

def self.connect_token(token, options=nil)
  options = custom_options(options)
  url = options[:url]
  client = Heroics.token_client_from_schema(token, SCHEMA, url, options)
  Client.new(client)
end