Class: SoapyCake::AdminAddedit

Inherits:
Client
  • Object
show all
Includes:
Helper
Defined in:
lib/soapy_cake/admin_addedit.rb

Instance Attribute Summary

Attributes inherited from Client

#api_key, #domain, #time_offset

Instance Method Summary collapse

Methods included from Helper

#require_params, #validate_id, #walk_tree

Methods inherited from Client

#initialize

Constructor Details

This class inherits a constructor from SoapyCake::Client

Instance Method Details

#add_geo_targets(opts = {}) ⇒ Object



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

def add_geo_targets(opts = {})
  require_params(opts, %i(offer_contract_id countries set_targeting_to_geo))

  opts[:countries] = Array(opts[:countries]).join(',')

  run Request.new(:admin, :addedit, :geo_targets, opts.merge(add_edit_option: 'add'))
end

#add_offer(opts = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/soapy_cake/admin_addedit.rb', line 5

def add_offer(opts = {})
  require_params(opts, %i(
    hidden offer_status_id offer_type_id currency_id ssl click_cookie_days
    impression_cookie_days redirect_404 enable_view_thru_conversions
    click_trumps_impression disable_click_deduplication last_touch
    enable_transaction_id_deduplication postbacks_only fire_global_pixel
    fire_pixel_on_nonpaid_conversions offer_link thankyou_link from_lines
    subject_lines))

  addedit_offer(opts.merge(offer_id: 0))
end

#add_offer_contract(opts = {}) ⇒ Object



31
32
33
# File 'lib/soapy_cake/admin_addedit.rb', line 31

def add_offer_contract(opts = {})
  addedit_offer_contract(opts.merge(offer_contract_id: 0))
end

#add_offer_tier(opts = {}) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/soapy_cake/admin_addedit.rb', line 51

def add_offer_tier(opts = {})
  require_params(opts, %i(offer_id tier_id price_format_id offer_contract_id status_id))

  opts.merge!(
    redirect_offer_contract_id: -1,
    add_edit_option: 'add'
  )

  opts[:status_id] = const_lookup(:offer_status_id, opts[:status_id]) if opts.key?(:status_id)
  translate_values!(opts, %i(price_format_id))

  run Request.new(:admin, :addedit, :offer_tiers, opts)
end

#edit_offer(opts = {}) ⇒ Object



17
18
19
20
21
# File 'lib/soapy_cake/admin_addedit.rb', line 17

def edit_offer(opts = {})
  validate_id(opts, :offer_id)

  addedit_offer(opts)
end

#edit_offer_contract(opts = {}) ⇒ Object



35
36
37
38
39
# File 'lib/soapy_cake/admin_addedit.rb', line 35

def edit_offer_contract(opts = {})
  validate_id(opts, :offer_contract_id)

  addedit_offer_contract(opts)
end

#update_caps(opts = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/soapy_cake/admin_addedit.rb', line 41

def update_caps(opts = {})
  require_params(opts, %i(cap_type_id cap_interval_id cap_amount send_alert_only))

  translate_values!(opts, %i(cap_type_id cap_interval_id))

  opts[:cap_amount] = -1 if opts[:cap_interval_id] == const_lookup(:cap_interval_id, :disabled)

  run Request.new(:admin, :addedit, :caps, opts)
end