Class: Txbr::CampaignsApi
- Inherits:
-
Object
- Object
- Txbr::CampaignsApi
- Defined in:
- lib/txbr/campaigns_api.rb
Constant Summary collapse
- CAMPAIGN_BATCH_SIZE =
from braze docs
100- CAMPAIGN_LIST_PATH =
'campaigns/list'.freeze
- CAMPAIGN_DETAILS_PATH =
'campaigns/details'.freeze
Instance Attribute Summary collapse
-
#braze_api ⇒ Object
readonly
Returns the value of attribute braze_api.
Instance Method Summary collapse
- #details(campaign_id:) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(braze_api) ⇒ CampaignsApi
constructor
A new instance of CampaignsApi.
Constructor Details
#initialize(braze_api) ⇒ CampaignsApi
Returns a new instance of CampaignsApi.
9 10 11 |
# File 'lib/txbr/campaigns_api.rb', line 9 def initialize(braze_api) @braze_api = braze_api end |
Instance Attribute Details
#braze_api ⇒ Object (readonly)
Returns the value of attribute braze_api.
7 8 9 |
# File 'lib/txbr/campaigns_api.rb', line 7 def braze_api @braze_api end |
Instance Method Details
#details(campaign_id:) ⇒ Object
25 26 27 |
# File 'lib/txbr/campaigns_api.rb', line 25 def details(campaign_id:) braze_api.get_json(CAMPAIGN_DETAILS_PATH, campaign_id: campaign_id) end |
#each(&block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/txbr/campaigns_api.rb', line 13 def each(&block) return to_enum(__method__) unless block_given? page = 0 loop do campaigns = braze_api.get_json(CAMPAIGN_LIST_PATH, page: page) campaigns['campaigns'].each(&block) break if campaigns['campaigns'].size < CAMPAIGN_BATCH_SIZE page += 1 end end |