Class: HasOffers::Affiliate

Inherits:
Base
  • Object
show all
Defined in:
lib/hasoffers/affiliate.rb

Constant Summary collapse

Target =
'Affiliate'

Class Method Summary collapse

Methods inherited from Base

api_mode, api_mode=, base_uri, base_uri=, get_request, initialize_credentials, live?, post_request, requires!, test?

Class Method Details

.create(data, return_object = false) ⇒ Object


9
10
11
12
13
14
15
16
# File 'lib/hasoffers/affiliate.rb', line 9

def create(data, return_object = false)
  requires!(data, %w[company address1 city country zipcode phone])
  if data['country'] == 'US' or data['country'] == 'CA'
    requires!(data, 'region')
  end
  params = build_data(data, return_object)
  post_request(Target, 'create', params)
end

.update(id, data, return_object = false) ⇒ Object


18
19
20
21
22
# File 'lib/hasoffers/affiliate.rb', line 18

def update(id, data, return_object = false)
  params = build_data(data, return_object)
  params['id'] = id
  post_request(Target, 'update', params)
end