Class: SoapyCake::Campaigns
- Inherits:
-
Object
- Object
- SoapyCake::Campaigns
- Includes:
- Helper
- Defined in:
- lib/soapy_cake/campaigns.rb
Constant Summary collapse
- ALL_PARAMS =
TODO: Figure out what ‘static_suppression` is for and whether it needs to be in the list.
%i[ account_status_id affiliate_id auto_disposition_delay_hours campaign_id clear_session_on_conversion currency_id expiration_date expiration_date_modification_type media_type_id offer_contract_id offer_id paid paid_redirects paid_upsells payout payout_update_option pixel_html postback_delay_ms postback_url redirect_404 redirect_domain redirect_offer_contract_id review test_link third_party_name unique_key_hash use_offer_contract_payout ].freeze
- NO_CHANGE_VALUES =
{ account_status_id: 0, expiration_date_modification_type: ModificationType::DO_NOT_CHANGE, currency_id: 0, use_offer_contract_payout: 'no_change', payout_update_option: ModificationType::DO_NOT_CHANGE, paid: 'no_change', paid_redirects: 'no_change', paid_upsells: 'no_change', review: 'no_change', auto_disposition_delay_hours: -1, redirect_offer_contract_id: 0, redirect_404: 'no_change', clear_session_on_conversion: 'no_change', postback_delay_ms: -1 }.freeze
Instance Method Summary collapse
- #create(opts = {}) ⇒ Object
- #get(opts = {}) ⇒ Object
-
#patch(campaign_id, opts = {}) ⇒ Object
The default for ‘display_link_type_id` is “Fallback” in Cake, which doesn’t have an ID and, hence, cannot be set via the API.
- #update(campaign_id, opts = {}) ⇒ Object
Methods included from Helper
#const_lookup, #future_expiration_date, #require_params, #translate_booleans, #translate_values, #validate_id, #walk_tree
Instance Method Details
#create(opts = {}) ⇒ Object
42 43 44 45 |
# File 'lib/soapy_cake/campaigns.rb', line 42 def create(opts = {}) response = addedit_campaign(opts.merge(campaign_id: 0)) response.fetch(:success_info).fetch(:campaign_id) end |
#get(opts = {}) ⇒ Object
38 39 40 |
# File 'lib/soapy_cake/campaigns.rb', line 38 def get(opts = {}) client.run Request.new(:admin, :export, :campaigns, opts) end |
#patch(campaign_id, opts = {}) ⇒ Object
The default for ‘display_link_type_id` is “Fallback” in Cake, which doesn’t have an ID and, hence, cannot be set via the API. In order to not change it, it has to be absent from the request.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/soapy_cake/campaigns.rb', line 60 def patch(campaign_id, opts = {}) campaign = get(campaign_id: campaign_id).first opts = NO_CHANGE_VALUES .merge( affiliate_id: campaign.fetch(:affiliate).fetch(:affiliate_id), media_type_id: campaign.fetch(:media_type).fetch(:media_type_id), offer_contract_id: campaign.fetch(:offer_contract).fetch(:offer_contract_id), offer_id: campaign.fetch(:offer).fetch(:offer_id), payout: campaign.fetch(:payout).fetch(:amount), payout_update_option: 'do_not_change', pixel_html: campaign.dig(:pixel_info, :pixel_html) || '', postback_url: campaign.dig(:pixel_info, :postback_url) || '', redirect_domain: campaign.fetch(:redirect_domain, ''), test_link: campaign[:test_link] || '', unique_key_hash: campaign.dig(:pixel_info, :hash_type, :hash_type_id) || 'none', third_party_name: campaign.fetch(:third_party_name, '') ) .merge(opts) update(campaign_id, opts) nil end |
#update(campaign_id, opts = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/soapy_cake/campaigns.rb', line 47 def update(campaign_id, opts = {}) opts = opts.merge(campaign_id: campaign_id) opts = opts.merge(payout.(opts)) opts = opts.merge(expiration_date.(opts)) opts = NO_CHANGE_VALUES.merge(opts) require_params(opts, ALL_PARAMS) addedit_campaign(opts) nil end |