Class: Affilinet::Client

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

Constant Summary collapse

HOST =
'product-api.affili.net/'
SERVICE =
'productservice.svc/'
API_TYPE =
'JSON'
API_VERSION =
'V3/'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/affilinet/client.rb', line 9

def initialize(options={})
  @options = {ssl: true, image_scales: [], logo_scales: [], shop_ids: [], category_ids: [], facets: []}
  @options.merge! options
  uri = @options[:ssl] ? 'https://' : 'http://'
  uri.concat HOST

  @uri = URI.join uri, API_VERSION, SERVICE, API_TYPE
  @publisher_id = @options[:publisher_id]
  @password = @options[:password]

  @connection = connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.

Raises:

  • (ArgumentError)


7
8
9
# File 'lib/affilinet/client.rb', line 7

def connection
  @connection
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/affilinet/client.rb', line 7

def options
  @options
end

#passwordObject (readonly)

Returns the value of attribute password.



7
8
9
# File 'lib/affilinet/client.rb', line 7

def password
  @password
end

#publisher_idObject (readonly)

Returns the value of attribute publisher_id.



7
8
9
# File 'lib/affilinet/client.rb', line 7

def publisher_id
  @publisher_id
end

#uriObject (readonly)

Returns the value of attribute uri.



7
8
9
# File 'lib/affilinet/client.rb', line 7

def uri
  @uri
end

Instance Method Details

#categoriesObject



37
38
39
# File 'lib/affilinet/client.rb', line 37

def categories
  Affilinet::Category.new self
end

#get(endpoint, args = {}) ⇒ Object



33
34
35
# File 'lib/affilinet/client.rb', line 33

def get endpoint, args = {}
  connection.get(endpoint, args).body
end

#productsObject



45
46
47
# File 'lib/affilinet/client.rb', line 45

def products
  Affilinet::Product.new self
end

#propertiesObject



41
42
43
# File 'lib/affilinet/client.rb', line 41

def properties
  Affilinet::Property.new self
end

#searchObject



53
54
55
# File 'lib/affilinet/client.rb', line 53

def search
  Affilinet::Search.new self
end

#shopsObject



49
50
51
# File 'lib/affilinet/client.rb', line 49

def shops
  Affilinet::Shop.new self
end