Class: SoapyCake::AdminAddedit
- Includes:
- Helper
- Defined in:
- lib/soapy_cake/admin_addedit.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- OFFER_DEFAULT_OPTIONS =
{ offer_name: '', third_party_name: '', hidden: 'no_change', offer_status_id: 0, ssl: 'no_change', click_cookie_days: -1, impression_cookie_days: -1, redirect_offer_contract_id: 0, redirect_404: 'no_change', enable_view_thru_conversions: 'no_change', click_trumps_impression: 'no_change', disable_click_deduplication: 'no_change', last_touch: 'no_change', enable_transaction_id_deduplication: 'no_change', postbacks_only: 'no_change', pixel_html: '', postback_url: '', fire_global_pixel: 'no_change', fire_pixel_on_nonpaid_conversions: 'no_change', expiration_date_modification_type: 'do_not_change', offer_contract_name: '', offer_link: '', thankyou_link: '', preview_link: '', thumbnail_file_import_url: '', offer_description: '', restrictions: '', advertiser_extended_terms: '', testing_instructions: '', allow_affiliates_to_create_creatives: 'no_change', unsubscribe_link: '', from_lines: '', subject_lines: '', conversions_from_whitelist_only: 'off', allowed_media_type_modification_type: 'do_not_change', track_search_terms_from_non_supported_search_engines: 'off', auto_disposition_type: 'none', auto_disposition_delay_hours: '0', session_regeneration_seconds: -1, session_regeneration_type_id: 0, payout_modification_type: 'change', received_modification_type: 'change', tags_modification_type: 'do_not_change' }.freeze
- REQUIRED_NEW_OFFER_PARAMS =
%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 ).freeze
- REQUIRED_OFFER_PARAMS =
%i( advertiser_id vertical_id postback_url_ms_delay offer_contract_hidden price_format_id received received_percentage payout tags ).freeze
- REQUIRED_OFFER_CONTRACT_PARAMS =
%i( offer_id offer_contract_id offer_contract_name price_format_id payout received received_percentage offer_link thankyou_link offer_contract_hidden offer_contract_is_default use_fallback_targeting ).freeze
Instance Attribute Summary
Attributes inherited from Client
#api_key, #domain, #time_offset
Instance Method Summary collapse
- #add_campaign(opts) ⇒ Object
- #add_geo_targets(opts) ⇒ Object
- #add_offer(opts) ⇒ Object
- #add_offer_contract(opts = {}) ⇒ Object
- #add_offer_tier(opts) ⇒ Object
- #edit_affiliate(opts) ⇒ Object
- #edit_campaign(opts) ⇒ Object
- #edit_contact(opts) ⇒ Object
- #edit_offer(opts = {}) ⇒ Object
- #edit_offer_contract(opts = {}) ⇒ Object
- #edit_offer_tier(opts) ⇒ Object
- #geo_targets_allow_options(opts) ⇒ Object
- #geo_targets_redirect_options(opts) ⇒ Object
- #remove_caps(opts) ⇒ Object
- #update_caps(opts) ⇒ Object
Methods included from Helper
#const_lookup, #future_expiration_date, #require_params, #translate_booleans, #translate_values, #validate_id, #walk_tree
Methods inherited from Client
Constructor Details
This class inherits a constructor from SoapyCake::Client
Instance Method Details
#add_campaign(opts) ⇒ Object
166 167 168 |
# File 'lib/soapy_cake/admin_addedit.rb', line 166 def add_campaign(opts) addedit_campaign(opts.merge(campaign_id: 0)) end |
#add_geo_targets(opts) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/soapy_cake/admin_addedit.rb', line 90 def add_geo_targets(opts) require_params(opts, %i(offer_contract_id allow_countries)) if opts[:allow_countries] opts = (opts) else opts = (opts) end opts = opts.merge(add_edit_option: 'add', set_targeting_to_geo: true) run Request.new(:admin, :addedit, :geo_targets, opts) end |
#add_offer(opts) ⇒ Object
72 73 74 75 76 |
# File 'lib/soapy_cake/admin_addedit.rb', line 72 def add_offer(opts) require_params(opts, REQUIRED_NEW_OFFER_PARAMS) addedit_offer(opts.merge(offer_id: 0)) end |
#add_offer_contract(opts = {}) ⇒ Object
125 126 127 |
# File 'lib/soapy_cake/admin_addedit.rb', line 125 def add_offer_contract(opts = {}) addedit_offer_contract(opts.merge(offer_contract_id: 0)) end |
#add_offer_tier(opts) ⇒ Object
152 153 154 |
# File 'lib/soapy_cake/admin_addedit.rb', line 152 def add_offer_tier(opts) addedit_offer_tier('add', opts) end |
#edit_affiliate(opts) ⇒ Object
160 161 162 163 164 |
# File 'lib/soapy_cake/admin_addedit.rb', line 160 def edit_affiliate(opts) require_params(opts, %i(affiliate_id vat_tax_required)) run Request.new(:admin, :addedit, :affiliate, opts) end |
#edit_campaign(opts) ⇒ Object
170 171 172 173 174 175 |
# File 'lib/soapy_cake/admin_addedit.rb', line 170 def edit_campaign(opts) require_params(opts, %i(campaign_id)) validate_id(opts, :campaign_id) addedit_campaign(opts) end |
#edit_contact(opts) ⇒ Object
84 85 86 87 88 |
# File 'lib/soapy_cake/admin_addedit.rb', line 84 def edit_contact(opts) require_params(opts, %i(entity_id contact_id contact_email_address)) run Request.new(:admin, :addedit, :contact, opts) end |
#edit_offer(opts = {}) ⇒ Object
78 79 80 81 82 |
# File 'lib/soapy_cake/admin_addedit.rb', line 78 def edit_offer(opts = {}) validate_id(opts, :offer_id) addedit_offer(opts) end |
#edit_offer_contract(opts = {}) ⇒ Object
129 130 131 132 133 |
# File 'lib/soapy_cake/admin_addedit.rb', line 129 def edit_offer_contract(opts = {}) validate_id(opts, :offer_contract_id) addedit_offer_contract(opts) end |
#edit_offer_tier(opts) ⇒ Object
156 157 158 |
# File 'lib/soapy_cake/admin_addedit.rb', line 156 def edit_offer_tier(opts) addedit_offer_tier('replace', opts) end |
#geo_targets_allow_options(opts) ⇒ Object
104 105 106 107 108 109 110 111 |
# File 'lib/soapy_cake/admin_addedit.rb', line 104 def (opts) require_params(opts, %i(countries)) opts = opts.dup countries = Array(opts[:countries]) opts[:countries] = countries.join(',') opts[:redirect_offer_contract_ids] = ([-1] * countries.count).join(',') opts end |
#geo_targets_redirect_options(opts) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/soapy_cake/admin_addedit.rb', line 113 def (opts) opts = opts.dup redirects = opts.delete(:redirects) unless redirects.is_a?(Hash) && redirects.keys.count > 0 fail Error, "Parameter 'redirects' must be a COUNTRY=>REDIRECT_OFFER_CONTRACT_ID hash!" end opts[:countries] = redirects.keys.join(',') opts[:redirect_offer_contract_ids] = redirects.values.join(',') opts end |
#remove_caps(opts) ⇒ Object
143 144 145 146 147 148 149 150 |
# File 'lib/soapy_cake/admin_addedit.rb', line 143 def remove_caps(opts) require_params(opts, %i(cap_type_id)) opts = translate_values(opts, %i(cap_type_id)) opts = opts.merge(cap_interval_id: 0, cap_amount: -1, send_alert_only: false) run Request.new(:admin, :addedit, :caps, opts) end |
#update_caps(opts) ⇒ Object
135 136 137 138 139 140 141 |
# File 'lib/soapy_cake/admin_addedit.rb', line 135 def update_caps(opts) require_params(opts, %i(cap_type_id cap_interval_id cap_amount send_alert_only)) opts = translate_values(opts, %i(cap_type_id cap_interval_id)) run Request.new(:admin, :addedit, :caps, opts) end |