diff --git a/lib/appboy/api.rb b/lib/appboy/api.rb index ec8dcf3..d8ba18d 100644 --- a/lib/appboy/api.rb +++ b/lib/appboy/api.rb @@ -20,17 +20,17 @@ class API include Appboy::Endpoints::TriggerCanvas def export_users(**payload) - Appboy::REST::ExportUsers.new.perform(app_group_id, payload) + Appboy::REST::ExportUsers.new(api_key).perform(payload) end def list_segments - Appboy::REST::ListSegments.new.perform(app_group_id) + Appboy::REST::ListSegments.new(api_key).perform end - attr_reader :app_group_id + attr_reader :api_key - def initialize(app_group_id) - @app_group_id = app_group_id + def initialize(api_key) + @api_key = api_key end end end diff --git a/lib/appboy/endpoints/delete_users.rb b/lib/appboy/endpoints/delete_users.rb index 6f1e8ae..d8ea81a 100644 --- a/lib/appboy/endpoints/delete_users.rb +++ b/lib/appboy/endpoints/delete_users.rb @@ -2,7 +2,7 @@ module Appboy module Endpoints module DeleteUsers def delete_users(**payload) - delete_users_service.new(app_group_id, payload).perform + delete_users_service.new(api_key, payload).perform end private diff --git a/lib/appboy/endpoints/email_status.rb b/lib/appboy/endpoints/email_status.rb index c19bc5c..ffffd5b 100644 --- a/lib/appboy/endpoints/email_status.rb +++ b/lib/appboy/endpoints/email_status.rb @@ -2,7 +2,7 @@ module Appboy module Endpoints module EmailStatus def email_status(**payload) - email_status_service.new(app_group_id, payload).perform + email_status_service.new(api_key, payload).perform end def email_status_service diff --git a/lib/appboy/endpoints/schedule_messages.rb b/lib/appboy/endpoints/schedule_messages.rb index 707141d..8cb76ef 100644 --- a/lib/appboy/endpoints/schedule_messages.rb +++ b/lib/appboy/endpoints/schedule_messages.rb @@ -2,7 +2,7 @@ module Appboy module Endpoints module ScheduleMessages def schedule_messages(**payload) - schedule_messages_service.new(app_group_id, payload).perform + schedule_messages_service.new(api_key, payload).perform end private diff --git a/lib/appboy/endpoints/send_messages.rb b/lib/appboy/endpoints/send_messages.rb index c2921e8..b1e97fa 100644 --- a/lib/appboy/endpoints/send_messages.rb +++ b/lib/appboy/endpoints/send_messages.rb @@ -2,7 +2,7 @@ module Appboy module Endpoints module SendMessages def send_messages(**payload) - send_messages_service.new(app_group_id, payload).perform + send_messages_service.new(api_key, payload).perform end private diff --git a/lib/appboy/endpoints/track_users.rb b/lib/appboy/endpoints/track_users.rb index f8a7754..4f815fe 100644 --- a/lib/appboy/endpoints/track_users.rb +++ b/lib/appboy/endpoints/track_users.rb @@ -4,7 +4,7 @@ module TrackUsers attr_writer :track_users_service def track_users(**payload) - track_users_service.perform(app_group_id, payload) + track_users_service.perform(payload) end def track_purchase(payload) @@ -22,7 +22,7 @@ def track_attribute(payload) private def track_users_service - @track_users_service ||= Appboy::REST::TrackUsers.new + @track_users_service ||= Appboy::REST::TrackUsers.new(api_key) end end end diff --git a/lib/appboy/endpoints/trigger_campaign.rb b/lib/appboy/endpoints/trigger_campaign.rb index 48b8bc8..c08cd6f 100644 --- a/lib/appboy/endpoints/trigger_campaign.rb +++ b/lib/appboy/endpoints/trigger_campaign.rb @@ -2,7 +2,7 @@ module Appboy module Endpoints module TriggerCampaign def trigger_campaign(**payload) - trigger_campaign_service.new(app_group_id, payload).perform + trigger_campaign_service.new(api_key, payload).perform end private diff --git a/lib/appboy/endpoints/trigger_canvas.rb b/lib/appboy/endpoints/trigger_canvas.rb index 767cdd8..62ca3e4 100644 --- a/lib/appboy/endpoints/trigger_canvas.rb +++ b/lib/appboy/endpoints/trigger_canvas.rb @@ -2,7 +2,7 @@ module Appboy module Endpoints module TriggerCanvas def trigger_canvas(**payload) - trigger_canvas_service.new(app_group_id, payload).perform + trigger_canvas_service.new(api_key, payload).perform end private diff --git a/lib/appboy/http.rb b/lib/appboy/http.rb index 2d2ef47..4bb9e74 100644 --- a/lib/appboy/http.rb +++ b/lib/appboy/http.rb @@ -3,18 +3,25 @@ module Appboy class HTTP + attr_reader :api_key + + def initialize(api_key) + @api_key = api_key + end + def post(path, payload) connection.post path do |request| request.body = payload end end - def get(path, query) + def get(path, query = {}) connection.get path, query end def connection - @connection ||= Faraday.new(url: api_host) do |connection| + @connection ||= Faraday.new(url: api_host, + headers: { Authorization: "Bearer #{api_key}" }) do |connection| connection.request :json connection.response :logger if ENV['APPBOY_DEBUG'] diff --git a/lib/appboy/rest/base.rb b/lib/appboy/rest/base.rb index fafead0..c3131e0 100644 --- a/lib/appboy/rest/base.rb +++ b/lib/appboy/rest/base.rb @@ -4,11 +4,16 @@ module Appboy module REST class Base attr_writer :http + attr_reader :api_key + + def initialize(api_key) + @api_key = api_key + end private def http - @http ||= Appboy::HTTP.new + @http ||= Appboy::HTTP.new(api_key) end end end diff --git a/lib/appboy/rest/delete_users.rb b/lib/appboy/rest/delete_users.rb index d7f1258..1ffb102 100644 --- a/lib/appboy/rest/delete_users.rb +++ b/lib/appboy/rest/delete_users.rb @@ -1,17 +1,16 @@ module Appboy module REST class DeleteUsers < Base - attr_reader :app_group_id, :external_ids, :appboy_ids + attr_reader :external_ids, :appboy_ids - def initialize(app_group_id, external_ids: [], appboy_ids: []) - @app_group_id = app_group_id + def initialize(api_key, external_ids: [], appboy_ids: []) + super(api_key) @external_ids = external_ids @appboy_ids = appboy_ids end def perform http.post '/users/delete', { - app_group_id: app_group_id, external_ids: external_ids, appboy_ids: appboy_ids } diff --git a/lib/appboy/rest/email_status.rb b/lib/appboy/rest/email_status.rb index 5acebc5..0b9f09e 100644 --- a/lib/appboy/rest/email_status.rb +++ b/lib/appboy/rest/email_status.rb @@ -1,17 +1,16 @@ module Appboy module REST class EmailStatus < Base - attr_reader :app_group_id, :email, :status + attr_reader :email, :status - def initialize(app_group_id, email:, status:) - @app_group_id = app_group_id + def initialize(api_key, email:, status:) + super(api_key) @email = email @status = status end def perform http.post '/email/status', { - app_group_id: app_group_id, email: email, subscription_state: status } diff --git a/lib/appboy/rest/export_users.rb b/lib/appboy/rest/export_users.rb index 10750c2..c32484b 100644 --- a/lib/appboy/rest/export_users.rb +++ b/lib/appboy/rest/export_users.rb @@ -1,24 +1,22 @@ module Appboy module REST class ExportUsers < Base - def perform(app_group_id, external_ids: nil, segment_id: nil, **options) - return export_users_by_ids(app_group_id, external_ids) if external_ids + def perform(external_ids: nil, segment_id: nil, **options) + return export_users_by_ids(external_ids) if external_ids - export_users_by_segment(app_group_id, segment_id, options) if segment_id + export_users_by_segment(segment_id, options) if segment_id end private - def export_users_by_ids(app_group_id, external_ids) + def export_users_by_ids(external_ids) http.post '/users/export/ids', { - app_group_id: app_group_id, external_ids: external_ids } end - def export_users_by_segment(app_group_id, segment_id, options) + def export_users_by_segment(segment_id, options) http.post '/users/export/segment', { - app_group_id: app_group_id, segment_id: segment_id }.merge(options) end diff --git a/lib/appboy/rest/list_segments.rb b/lib/appboy/rest/list_segments.rb index 785b285..8516d5c 100644 --- a/lib/appboy/rest/list_segments.rb +++ b/lib/appboy/rest/list_segments.rb @@ -1,10 +1,8 @@ module Appboy module REST class ListSegments < Base - def perform(app_group_id) - http.get '/segments/list', { - app_group_id: app_group_id - } + def perform + http.get '/segments/list' end end end diff --git a/lib/appboy/rest/schedule_messages.rb b/lib/appboy/rest/schedule_messages.rb index cb41589..28e01a1 100644 --- a/lib/appboy/rest/schedule_messages.rb +++ b/lib/appboy/rest/schedule_messages.rb @@ -1,22 +1,23 @@ module Appboy module REST class ScheduleMessages < Base - attr_reader :app_group_id, :send_at, :messages, :segment_id, :local_timezone + attr_reader :time, :messages, :external_user_ids, :local_timezone - def initialize(app_group_id, send_at:, messages: [], segment_id: nil, local_timezone: false) - @app_group_id = app_group_id - @send_at = send_at + def initialize(api_key, time:, messages: [], external_user_ids: [], local_timezone: false) + super(api_key) + @time = time @messages = messages - @segment_id = segment_id + @external_user_ids = external_user_ids @local_timezone = local_timezone end def perform - http.post '/messages/schedule', { - app_group_id: app_group_id, - segment_ids: [segment_id], - send_at: send_at, - deliver_in_local_timezone: local_timezone, + http.post '/messages/schedule/create', { + external_user_ids: external_user_ids, + schedule: { + time: time, + in_local_time: local_timezone + }, messages: messages } end diff --git a/lib/appboy/rest/send_messages.rb b/lib/appboy/rest/send_messages.rb index 7bb01c8..371db81 100644 --- a/lib/appboy/rest/send_messages.rb +++ b/lib/appboy/rest/send_messages.rb @@ -1,10 +1,10 @@ module Appboy module REST class SendMessages < Base - attr_reader :app_group_id, :messages, :external_user_ids, :segment_id + attr_reader :messages, :external_user_ids, :segment_id - def initialize(app_group_id, messages: [], external_user_ids: [], segment_id: nil) - @app_group_id = app_group_id + def initialize(api_key, messages: [], external_user_ids: [], segment_id: nil) + super(api_key) @messages = messages @external_user_ids = external_user_ids @segment_id = segment_id @@ -12,7 +12,6 @@ def initialize(app_group_id, messages: [], external_user_ids: [], segment_id: ni def perform http.post '/messages/send', { - app_group_id: app_group_id, messages: messages, external_user_ids: external_user_ids, segment_ids: [segment_id].compact diff --git a/lib/appboy/rest/track_users.rb b/lib/appboy/rest/track_users.rb index 46bf73c..31ca69c 100644 --- a/lib/appboy/rest/track_users.rb +++ b/lib/appboy/rest/track_users.rb @@ -1,9 +1,8 @@ module Appboy module REST class TrackUsers < Base - def perform(app_group_id, attributes: [], events: [], purchases: []) + def perform(attributes: [], events: [], purchases: []) http.post '/users/track', { - app_group_id: app_group_id, attributes: attributes, events: events, purchases: purchases diff --git a/lib/appboy/rest/trigger_campaign.rb b/lib/appboy/rest/trigger_campaign.rb index 256330d..48ebec0 100644 --- a/lib/appboy/rest/trigger_campaign.rb +++ b/lib/appboy/rest/trigger_campaign.rb @@ -1,11 +1,11 @@ module Appboy module REST class TriggerCampaign < Base - attr_reader :api_key, :audience, :broadcast, :campaign_id, + attr_reader :audience, :broadcast, :campaign_id, :recipients, :send_id, :trigger_properties def initialize(api_key, options = {}) - @api_key = api_key + super(api_key) @audience = options[:audience] @broadcast = options[:broadcast] || false @campaign_id = options[:campaign_id] @@ -16,7 +16,6 @@ def initialize(api_key, options = {}) def perform http.post '/campaigns/trigger/send', { - api_key: api_key, audience: audience, broadcast: broadcast, campaign_id: campaign_id, diff --git a/lib/appboy/rest/trigger_canvas.rb b/lib/appboy/rest/trigger_canvas.rb index 1927595..b9f81ba 100644 --- a/lib/appboy/rest/trigger_canvas.rb +++ b/lib/appboy/rest/trigger_canvas.rb @@ -1,11 +1,10 @@ module Appboy module REST class TriggerCanvas < Base - attr_reader :api_key, :audience, :broadcast, :canvas_id, - :canvas_entry_properties, :recipients + attr_reader :audience, :broadcast, :canvas_id, :canvas_entry_properties, :recipients - def initialize(app_group_id, options = {}) - @api_key = app_group_id + def initialize(api_key, options = {}) + super(api_key) @audience = options[:audience] @broadcast = options[:broadcast] || false @canvas_entry_properties = options[:canvas_entry_properties] @@ -15,7 +14,6 @@ def initialize(app_group_id, options = {}) def perform http.post '/canvas/trigger/send', { - api_key: api_key, audience: audience, broadcast: broadcast, canvas_entry_properties: canvas_entry_properties, diff --git a/lib/appboy/version.rb b/lib/appboy/version.rb index 0231c55..c395154 100644 --- a/lib/appboy/version.rb +++ b/lib/appboy/version.rb @@ -1,3 +1,3 @@ module Appboy - VERSION = '0.1.6' + VERSION = '0.1.7' end diff --git a/spec/appboy/endpoints/track_users_spec.rb b/spec/appboy/endpoints/track_users_spec.rb index b94998b..a45665d 100644 --- a/spec/appboy/endpoints/track_users_spec.rb +++ b/spec/appboy/endpoints/track_users_spec.rb @@ -3,8 +3,8 @@ class API include Appboy::Endpoints::TrackUsers - def app_group_id - :app_group_id + def api_key + :api_key end end @@ -25,7 +25,7 @@ def app_group_id it 'tracks attributes, events and purchases' do expect(track_users_service).to receive(:perform) - .with(:app_group_id, payload) + .with(payload) track_users! end @@ -38,7 +38,7 @@ def app_group_id it 'tracks a single purchase' do expect(track_users_service).to receive(:perform) - .with(:app_group_id, purchases: [payload]) + .with(purchases: [payload]) track_purchase! end @@ -51,7 +51,7 @@ def app_group_id it 'tracks a single purchase' do expect(track_users_service).to receive(:perform) - .with(:app_group_id, events: [payload]) + .with(events: [payload]) track_event! end @@ -64,7 +64,7 @@ def app_group_id it 'tracks a single purchase' do expect(track_users_service).to receive(:perform) - .with(:app_group_id, attributes: [payload]) + .with(attributes: [payload]) track_attribute! end diff --git a/spec/appboy/endpoints/trigger_campaigns_spec.rb b/spec/appboy/endpoints/trigger_campaigns_spec.rb index e99d4b1..537c1cb 100644 --- a/spec/appboy/endpoints/trigger_campaigns_spec.rb +++ b/spec/appboy/endpoints/trigger_campaigns_spec.rb @@ -4,7 +4,7 @@ class API include Appboy::Endpoints::TriggerCampaign - def app_group_id + def api_key :api_key end end diff --git a/spec/appboy/endpoints/trigger_canvas_spec.rb b/spec/appboy/endpoints/trigger_canvas_spec.rb index ce57e5a..8a271dc 100644 --- a/spec/appboy/endpoints/trigger_canvas_spec.rb +++ b/spec/appboy/endpoints/trigger_canvas_spec.rb @@ -4,7 +4,7 @@ class API include Appboy::Endpoints::TriggerCanvas - def app_group_id + def api_key :api_key end end diff --git a/spec/appboy/http_spec.rb b/spec/appboy/http_spec.rb index 7fd0d28..df8e171 100644 --- a/spec/appboy/http_spec.rb +++ b/spec/appboy/http_spec.rb @@ -2,6 +2,9 @@ require 'appboy/http' describe Appboy::HTTP do + + subject { described_class.new(:api_key) } + describe '#connection' do it 'sets the default url prefix' do expect(subject.connection.url_prefix.to_s).to eql "https://api.appboy.com/" diff --git a/spec/appboy/rest/delete_users_spec.rb b/spec/appboy/rest/delete_users_spec.rb index e8524da..4cbbf55 100644 --- a/spec/appboy/rest/delete_users_spec.rb +++ b/spec/appboy/rest/delete_users_spec.rb @@ -8,15 +8,15 @@ appboy_ids: :appboy_ids }} - let(:app_group_id) { :app_group_id } + let(:api_key) { :api_key } - subject { described_class.new(:app_group_id, external_ids: :external_ids, appboy_ids: :appboy_ids) } + subject { described_class.new(:api_key, external_ids: :external_ids, appboy_ids: :appboy_ids) } before { subject.http = http } it 'makes an http call to the track user endpoint' do expect(http).to receive(:post).with '/users/delete', - payload.merge({ app_group_id: :app_group_id }) + payload subject.perform end diff --git a/spec/appboy/rest/email_status_spec.rb b/spec/appboy/rest/email_status_spec.rb index 41a2e98..424598b 100644 --- a/spec/appboy/rest/email_status_spec.rb +++ b/spec/appboy/rest/email_status_spec.rb @@ -5,11 +5,10 @@ before { subject.http = http } - subject { described_class.new(:app_group_id, email: :email, status: :status) } + subject { described_class.new(:api_key, email: :email, status: :status) } it 'makes an http call to the email status endpoint' do expect(http).to receive(:post).with '/email/status', { - app_group_id: :app_group_id, email: :email, subscription_state: :status } diff --git a/spec/appboy/rest/export_users_spec.rb b/spec/appboy/rest/export_users_spec.rb index 56fb90b..61ae5c2 100644 --- a/spec/appboy/rest/export_users_spec.rb +++ b/spec/appboy/rest/export_users_spec.rb @@ -5,16 +5,16 @@ let(:payload) {{ external_ids: :external_ids }} - let(:app_group_id) { :app_group_id } + let(:api_key) { :api_key } - subject { described_class.new } + subject { described_class.new(api_key) } before { subject.http = http } it 'makes an http call to the track user endpoint' do expect(http).to receive(:post).with '/users/export/ids', - payload.merge({ app_group_id: :app_group_id }) + payload - subject.perform(app_group_id, payload) + subject.perform(payload) end end diff --git a/spec/appboy/rest/schedule_messages_spec.rb b/spec/appboy/rest/schedule_messages_spec.rb index 0e55e5e..52c1bb2 100644 --- a/spec/appboy/rest/schedule_messages_spec.rb +++ b/spec/appboy/rest/schedule_messages_spec.rb @@ -4,15 +4,15 @@ let(:http) { double(:http) } let(:payload) {{ - send_at: :send_at, - segment_id: :segment_id, + time: :time, + external_user_ids: [:external_user_ids], local_timezone: :local_timezone, messages: :messages }} - let(:app_group_id) { :app_group_id } + let(:api_key) { :api_key } - subject { described_class.new(app_group_id, payload) } + subject { described_class.new(api_key, payload) } before { subject.http = http } @@ -23,11 +23,12 @@ end def expect_schedule_messages_http_call - expect(http).to receive(:post).with '/messages/schedule', { - app_group_id: app_group_id, - segment_ids: [:segment_id], - send_at: :send_at, - deliver_in_local_timezone: :local_timezone, + expect(http).to receive(:post).with '/messages/schedule/create', { + external_user_ids: [:external_user_ids], + schedule: { + time: :time, + in_local_time: :local_timezone + }, messages: :messages } end diff --git a/spec/appboy/rest/send_messages_spec.rb b/spec/appboy/rest/send_messages_spec.rb index d420f97..32c81a5 100644 --- a/spec/appboy/rest/send_messages_spec.rb +++ b/spec/appboy/rest/send_messages_spec.rb @@ -9,9 +9,9 @@ segment_id: :segment_id }} - let(:app_group_id) { :app_group_id } + let(:api_key) { :api_key } - subject { described_class.new(app_group_id, + subject { described_class.new(api_key, messages: :messages, external_user_ids: :external_user_ids, segment_id: :segment_id @@ -27,7 +27,6 @@ def expect_send_messages_http_call expect(http).to receive(:post).with '/messages/send', { - app_group_id: :app_group_id, messages: :messages, external_user_ids: :external_user_ids, segment_ids: [:segment_id] diff --git a/spec/appboy/rest/track_users_spec.rb b/spec/appboy/rest/track_users_spec.rb index 1d33c32..4ff3562 100644 --- a/spec/appboy/rest/track_users_spec.rb +++ b/spec/appboy/rest/track_users_spec.rb @@ -9,16 +9,16 @@ purchases: :purchases }} - let(:app_group_id) { :app_group_id } + let(:api_key) { :api_key } - subject { described_class.new } + subject { described_class.new(api_key) } before { subject.http = http } it 'makes an http call to the track user endpoint' do expect(http).to receive(:post).with '/users/track', - payload.merge({ app_group_id: :app_group_id }) + payload - subject.perform(app_group_id, payload) + subject.perform(payload) end end diff --git a/spec/appboy/rest/trigger_campaign_spec.rb b/spec/appboy/rest/trigger_campaign_spec.rb index c050760..c730208 100644 --- a/spec/appboy/rest/trigger_campaign_spec.rb +++ b/spec/appboy/rest/trigger_campaign_spec.rb @@ -38,7 +38,6 @@ def expect_send_messages_http_call expect(http).to receive(:post).with '/campaigns/trigger/send', { - api_key: :api_key, audience: :audience, broadcast: :broadcast, campaign_id: :campaign_id, diff --git a/spec/appboy/rest/trigger_canvas_spec.rb b/spec/appboy/rest/trigger_canvas_spec.rb index b492ee8..4b85cee 100644 --- a/spec/appboy/rest/trigger_canvas_spec.rb +++ b/spec/appboy/rest/trigger_canvas_spec.rb @@ -36,7 +36,6 @@ def expect_send_messages_http_call expect(http).to receive(:post).with '/canvas/trigger/send', { - api_key: :api_key, audience: :audience, broadcast: :broadcast, canvas_id: :canvas_id, diff --git a/spec/fixtures/responses/delete_users/unauthorized/responds_with_unauthorized.yml b/spec/fixtures/responses/delete_users/unauthorized/responds_with_unauthorized.yml index 05dde35..2b96c78 100644 --- a/spec/fixtures/responses/delete_users/unauthorized/responds_with_unauthorized.yml +++ b/spec/fixtures/responses/delete_users/unauthorized/responds_with_unauthorized.yml @@ -5,10 +5,12 @@ http_interactions: uri: https://api.appboy.com/users/delete body: encoding: UTF-8 - string: '{"app_group_id":"non-existent","external_ids":[1,2],"appboy_ids":[]}' + string: '{"external_ids":[1,2],"appboy_ids":[]}' headers: + Authorization: + - Bearer non-existent User-Agent: - - Faraday v0.12.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -20,39 +22,46 @@ http_interactions: code: 401 message: Unauthorized headers: + Connection: + - keep-alive + Content-Length: + - '69' Cache-Control: - no-cache Content-Type: - application/json Server: - - nginx/1.10.2 + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + X-Ratelimit-Limit: + - '' + X-Ratelimit-Remaining: + - '' + X-Ratelimit-Reset: + - '' X-Request-Id: - - 90baa9c2-258b-4231-8308-0153e89dffe2 + - 05d3d952-3814-43f3-af08-65bf90347cc9 X-Runtime: - - '0.005878' - Content-Length: - - '85' + - '0.001370' Accept-Ranges: - bytes Date: - - Tue, 27 Jun 2017 14:45:31 GMT + - Sat, 31 Oct 2020 02:46:38 GMT Via: - 1.1 varnish - Connection: - - keep-alive X-Served-By: - - cache-ord1737-ORD + - cache-fty21368-FTY X-Cache: - MISS X-Cache-Hits: - '0' X-Timer: - - S1498574732.800538,VS0,VE27 + - S1604112399.545045,VS0,VE59 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: encoding: ASCII-8BIT - string: '{"message":"Invalid App Group API Identifier: non-existent"}' - http_version: - recorded_at: Tue, 27 Jun 2017 14:45:31 GMT -recorded_with: VCR 3.0.3 + string: '{"message":"Invalid API key: non-existent"}' + recorded_at: Sat, 31 Oct 2020 02:46:38 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/delete_users/with_success/responds_with_created.yml b/spec/fixtures/responses/delete_users/with_success/responds_with_created.yml index 2056cd4..b52b4e7 100644 --- a/spec/fixtures/responses/delete_users/with_success/responds_with_created.yml +++ b/spec/fixtures/responses/delete_users/with_success/responds_with_created.yml @@ -5,10 +5,12 @@ http_interactions: uri: https://api.appboy.com/users/delete body: encoding: UTF-8 - string: '{"app_group_id":"","external_ids":[1,2],"appboy_ids":[]}' + string: '{"external_ids":[1,2],"appboy_ids":[]}' headers: + Authorization: + - Bearer User-Agent: - - Faraday v0.12.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -20,39 +22,49 @@ http_interactions: code: 201 message: Created headers: + Connection: + - keep-alive + Content-Length: + - '58' Cache-Control: - - no-cache + - max-age=0, private, must-revalidate Content-Type: - application/json + Etag: + - W/"65eb7f14d37c91dd4fabfb8d9e8818ca" Server: - - nginx/1.10.2 + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + - max-age=31536000; includeSubDomains + X-Ratelimit-Limit: + - '250000' + X-Ratelimit-Remaining: + - '249999' + X-Ratelimit-Reset: + - '1604113200' X-Request-Id: - - c0ea7c6b-9323-4e1d-9467-f04d29fd4084 + - 52e04470-cff8-433d-9e20-2fcb55b51817 X-Runtime: - - '0.005712' - Content-Length: - - '80' + - '0.009456' Accept-Ranges: - bytes Date: - - Tue, 27 Jun 2017 14:44:20 GMT + - Sat, 31 Oct 2020 02:46:36 GMT Via: - 1.1 varnish - Connection: - - keep-alive X-Served-By: - - cache-ord1747-ORD + - cache-fty21363-FTY X-Cache: - MISS X-Cache-Hits: - '0' X-Timer: - - S1498574660.342690,VS0,VE121 + - S1604112397.834894,VS0,VE67 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: encoding: ASCII-8BIT - string: '{"deleted":1,message":"success"}' - http_version: - recorded_at: Tue, 27 Jun 2017 14:44:20 GMT -recorded_with: VCR 3.0.3 + string: '{"deleted":2,"message":"success"}' + recorded_at: Sat, 31 Oct 2020 02:46:36 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/delete_users/with_success/responds_with_success_message.yml b/spec/fixtures/responses/delete_users/with_success/responds_with_success_message.yml index cd155df..0a7f531 100644 --- a/spec/fixtures/responses/delete_users/with_success/responds_with_success_message.yml +++ b/spec/fixtures/responses/delete_users/with_success/responds_with_success_message.yml @@ -5,10 +5,12 @@ http_interactions: uri: https://api.appboy.com/users/delete body: encoding: UTF-8 - string: '{"app_group_id":"","external_ids":[1,2],"appboy_ids":[]}' + string: '{"external_ids":[1,2],"appboy_ids":[]}' headers: + Authorization: + - Bearer User-Agent: - - Faraday v0.12.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -20,39 +22,49 @@ http_interactions: code: 201 message: Created headers: + Connection: + - keep-alive + Content-Length: + - '58' Cache-Control: - - no-cache + - max-age=0, private, must-revalidate Content-Type: - application/json + Etag: + - W/"65eb7f14d37c91dd4fabfb8d9e8818ca" Server: - - nginx/1.10.2 + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + - max-age=31536000; includeSubDomains + X-Ratelimit-Limit: + - '250000' + X-Ratelimit-Remaining: + - '249998' + X-Ratelimit-Reset: + - '1604113200' X-Request-Id: - - 1e432499-cdf9-49c6-abc5-00354e59fe6b + - 872bf166-396e-4fc1-8e57-494b839c1c11 X-Runtime: - - '0.003536' - Content-Length: - - '80' + - '0.007129' Accept-Ranges: - bytes Date: - - Tue, 27 Jun 2017 14:44:22 GMT + - Sat, 31 Oct 2020 02:46:37 GMT Via: - 1.1 varnish - Connection: - - keep-alive X-Served-By: - - cache-ord1729-ORD + - cache-fty21347-FTY X-Cache: - MISS X-Cache-Hits: - '0' X-Timer: - - S1498574662.030820,VS0,VE24 + - S1604112398.668225,VS0,VE66 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: encoding: ASCII-8BIT string: '{"deleted":2,"message":"success"}' - http_version: - recorded_at: Tue, 27 Jun 2017 14:44:22 GMT -recorded_with: VCR 3.0.3 + recorded_at: Sat, 31 Oct 2020 02:46:37 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/email_status/existing_email/responds_with_created.yml b/spec/fixtures/responses/email_status/existing_email/responds_with_created.yml index dc14ed6..527c776 100644 --- a/spec/fixtures/responses/email_status/existing_email/responds_with_created.yml +++ b/spec/fixtures/responses/email_status/existing_email/responds_with_created.yml @@ -5,10 +5,12 @@ http_interactions: uri: https://api.appboy.com/email/status body: encoding: UTF-8 - string: '{"app_group_id":"","email":"john@example.com","subscription_state":"unsubscribed"}' + string: '{"email":"john@example.com","subscription_state":"unsubscribed"}' headers: + Authorization: + - Bearer User-Agent: - - Faraday v0.9.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -20,35 +22,49 @@ http_interactions: code: 201 message: Created headers: - Server: - - nginx/1.6.2 - Date: - - Thu, 19 Feb 2015 20:42:25 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked Connection: - keep-alive - Status: - - 201 Created - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 - Etag: - - '"8736cdfe08480bca66cffeee06268705"' + Content-Length: + - '46' Cache-Control: - max-age=0, private, must-revalidate + Content-Type: + - application/json + Etag: + - W/"838a7c62adda8d131d694ae13ba2c5b7" + Server: + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + - max-age=31536000; includeSubDomains + X-Ratelimit-Limit: + - '250000' + X-Ratelimit-Remaining: + - '249949' + X-Ratelimit-Reset: + - '1604329200' X-Request-Id: - - 664ec9e1c8bf8666cadff79ee1a56434 + - 1891e937-9f31-4088-8b4b-941453afbf27 X-Runtime: - - '0.024496' + - '0.011981' + Accept-Ranges: + - bytes + Date: + - Mon, 02 Nov 2020 14:56:04 GMT + Via: + - 1.1 varnish + X-Served-By: + - cache-fty21373-FTY + X-Cache: + - MISS + X-Cache-Hits: + - '0' + X-Timer: + - S1604328964.138044,VS0,VE69 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: - encoding: UTF-8 + encoding: ASCII-8BIT string: '{"message":"success"}' - http_version: - recorded_at: Thu, 19 Feb 2015 20:42:24 GMT -recorded_with: VCR 2.9.2 + recorded_at: Mon, 02 Nov 2020 14:56:04 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/email_status/existing_email/responds_with_success_message.yml b/spec/fixtures/responses/email_status/existing_email/responds_with_success_message.yml index aa2435a..8f71202 100644 --- a/spec/fixtures/responses/email_status/existing_email/responds_with_success_message.yml +++ b/spec/fixtures/responses/email_status/existing_email/responds_with_success_message.yml @@ -5,10 +5,12 @@ http_interactions: uri: https://api.appboy.com/email/status body: encoding: UTF-8 - string: '{"app_group_id":"","email":"john@example.com","subscription_state":"unsubscribed"}' + string: '{"email":"john@example.com","subscription_state":"unsubscribed"}' headers: + Authorization: + - Bearer User-Agent: - - Faraday v0.9.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -20,35 +22,49 @@ http_interactions: code: 201 message: Created headers: - Server: - - nginx/1.6.2 - Date: - - Thu, 19 Feb 2015 20:42:25 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked Connection: - keep-alive - Status: - - 201 Created - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 - Etag: - - '"8736cdfe08480bca66cffeee06268705"' + Content-Length: + - '46' Cache-Control: - max-age=0, private, must-revalidate + Content-Type: + - application/json + Etag: + - W/"838a7c62adda8d131d694ae13ba2c5b7" + Server: + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + - max-age=31536000; includeSubDomains + X-Ratelimit-Limit: + - '250000' + X-Ratelimit-Remaining: + - '249948' + X-Ratelimit-Reset: + - '1604329200' X-Request-Id: - - 0854d9c1be11939007bace0da4e264ac + - 6b2b0ceb-b179-46b2-92c9-703c6f7edeed X-Runtime: - - '0.025690' + - '0.008117' + Accept-Ranges: + - bytes + Date: + - Mon, 02 Nov 2020 14:56:10 GMT + Via: + - 1.1 varnish + X-Served-By: + - cache-fty21324-FTY + X-Cache: + - MISS + X-Cache-Hits: + - '0' + X-Timer: + - S1604328970.069151,VS0,VE66 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: - encoding: UTF-8 + encoding: ASCII-8BIT string: '{"message":"success"}' - http_version: - recorded_at: Thu, 19 Feb 2015 20:42:25 GMT -recorded_with: VCR 2.9.2 + recorded_at: Mon, 02 Nov 2020 14:56:10 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/email_status/unknown_email/responds_with_bad_request.yml b/spec/fixtures/responses/email_status/unknown_email/responds_with_bad_request.yml deleted file mode 100644 index ba807c5..0000000 --- a/spec/fixtures/responses/email_status/unknown_email/responds_with_bad_request.yml +++ /dev/null @@ -1,52 +0,0 @@ ---- -http_interactions: -- request: - method: post - uri: https://api.appboy.com/email/status - body: - encoding: UTF-8 - string: '{"app_group_id":"","email":"doesntexist@example.com","subscription_state":"unsubscribed"}' - headers: - User-Agent: - - Faraday v0.9.1 - Content-Type: - - application/json - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - response: - status: - code: 400 - message: Bad Request - headers: - Server: - - nginx/1.6.2 - Date: - - Thu, 19 Feb 2015 20:42:25 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked - Connection: - - keep-alive - Status: - - 400 Bad Request - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 - Cache-Control: - - no-cache - X-Request-Id: - - bf074c868b8c3a9c3d20dcecc7684d0b - X-Runtime: - - '0.015444' - Vary: - - Accept-Encoding - body: - encoding: UTF-8 - string: '{"message":"There is no user with the provided email"}' - http_version: - recorded_at: Thu, 19 Feb 2015 20:42:25 GMT -recorded_with: VCR 2.9.2 diff --git a/spec/fixtures/responses/email_status/unknown_email/responds_with_error_message.yml b/spec/fixtures/responses/email_status/unknown_email/responds_with_error_message.yml deleted file mode 100644 index 98523c8..0000000 --- a/spec/fixtures/responses/email_status/unknown_email/responds_with_error_message.yml +++ /dev/null @@ -1,52 +0,0 @@ ---- -http_interactions: -- request: - method: post - uri: https://api.appboy.com/email/status - body: - encoding: UTF-8 - string: '{"app_group_id":"","email":"doesntexist@example.com","subscription_state":"unsubscribed"}' - headers: - User-Agent: - - Faraday v0.9.1 - Content-Type: - - application/json - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - response: - status: - code: 400 - message: Bad Request - headers: - Server: - - nginx/1.6.2 - Date: - - Thu, 19 Feb 2015 20:42:25 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked - Connection: - - keep-alive - Status: - - 400 Bad Request - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 - Cache-Control: - - no-cache - X-Request-Id: - - 3817bbfc977af9d97686243969e9733f - X-Runtime: - - '0.015907' - Vary: - - Accept-Encoding - body: - encoding: UTF-8 - string: '{"message":"There is no user with the provided email"}' - http_version: - recorded_at: Thu, 19 Feb 2015 20:42:25 GMT -recorded_with: VCR 2.9.2 diff --git a/spec/fixtures/responses/export_users/by_ids/with_success/responds_with_created.yml b/spec/fixtures/responses/export_users/by_ids/with_success/responds_with_created.yml index bfc1550..22b94ab 100644 --- a/spec/fixtures/responses/export_users/by_ids/with_success/responds_with_created.yml +++ b/spec/fixtures/responses/export_users/by_ids/with_success/responds_with_created.yml @@ -5,10 +5,12 @@ http_interactions: uri: https://api.appboy.com/users/export/ids body: encoding: UTF-8 - string: '{"app_group_id":"","external_ids":[1]}' + string: '{"external_ids":[1]}' headers: + Authorization: + - Bearer User-Agent: - - Faraday v0.9.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -20,37 +22,49 @@ http_interactions: code: 201 message: Created headers: - Server: - - nginx/1.6.2 - Date: - - Thu, 26 Feb 2015 21:41:18 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked Connection: - keep-alive - Status: - - 201 Created - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 - Etag: - - '"051590a5519f8271c86bbaa59a309f47"' + Content-Length: + - '74' Cache-Control: - max-age=0, private, must-revalidate + Content-Type: + - application/json + Etag: + - W/"a2bffe53dd0293835943234b29bbd3ce" + Server: + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + - max-age=31536000; includeSubDomains + X-Ratelimit-Limit: + - '250000' + X-Ratelimit-Remaining: + - '249997' + X-Ratelimit-Reset: + - '1604113200' X-Request-Id: - - 25b7fb12aad1ffaea7b9f4f4752a0bec + - 8f13edcd-1d56-4ec4-b658-4c88f5a2cc21 X-Runtime: - - '1.105644' + - '0.035335' + Accept-Ranges: + - bytes + Date: + - Sat, 31 Oct 2020 02:48:19 GMT + Via: + - 1.1 varnish + X-Served-By: + - cache-fty21324-FTY + X-Cache: + - MISS + X-Cache-Hits: + - '0' + X-Timer: + - S1604112499.129989,VS0,VE92 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: - encoding: UTF-8 - string: '{"users":[{"external_id":"1","email":"john@example.com","total_revenue":97.09,"push_subscribe":"subscribed","email_subscribe":"opted_in","custom_attributes":{"custom_attribute":"Yes","foo":"fighters","capabilities":["Rewards","Custom - Survey Questions","Foo","Baz","K-invite","Multi-Redemption"]},"apps":[],"custom_events":[{"name":"baz","first":"2015-02-15T00:16:33Z","last":"2015-02-16T02:04:32Z","count":19},{"name":"Does - something significant","first":"2015-02-20T03:28:55Z","last":"2015-02-20T03:28:55Z","count":1}],"purchases":[{"name":null,"first":"2015-02-15T00:23:08Z","last":"2015-02-20T03:34:55Z","count":21},{"name":null,"first":"2015-02-20T03:35:44Z","last":"2015-02-20T03:35:44Z","count":1}]}],"invalid_user_ids":[1],"message":"success"}' - http_version: - recorded_at: Thu, 26 Feb 2015 21:41:18 GMT -recorded_with: VCR 2.9.2 + encoding: ASCII-8BIT + string: '{"users":[],"invalid_user_ids":[1],"message":"success"}' + recorded_at: Sat, 31 Oct 2020 02:48:19 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/export_users/by_segment/with_success/responds_with_created.yml b/spec/fixtures/responses/export_users/by_segment/with_success/responds_with_created.yml index cfb9696..5e2b9ee 100644 --- a/spec/fixtures/responses/export_users/by_segment/with_success/responds_with_created.yml +++ b/spec/fixtures/responses/export_users/by_segment/with_success/responds_with_created.yml @@ -5,10 +5,12 @@ http_interactions: uri: https://api.appboy.com/users/export/segment body: encoding: UTF-8 - string: '{"app_group_id":"","segment_id":"","callback_endpoint":"https://example.com"}' + string: '{"segment_id":"","callback_endpoint":"https://example.com"}' headers: + Authorization: + - Bearer User-Agent: - - Faraday v0.9.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -20,35 +22,49 @@ http_interactions: code: 201 message: Created headers: - Server: - - nginx/1.6.2 - Date: - - Tue, 24 Mar 2015 17:33:21 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked Connection: - keep-alive - Status: - - 201 Created - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 - Etag: - - '"0b603642a946afe389ef6c98459d8ba5"' + Content-Length: + - '190' Cache-Control: - max-age=0, private, must-revalidate + Content-Type: + - application/json + Etag: + - W/"517ec07d7db32fe4af594b7a6c4df92a" + Server: + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + - max-age=31536000; includeSubDomains + X-Ratelimit-Limit: + - '250000' + X-Ratelimit-Remaining: + - '249996' + X-Ratelimit-Reset: + - '1604113200' X-Request-Id: - - d51ea5a511c9ae34f37def7faa8c8799 + - 8f00a345-5056-4aaf-b959-e7c2322a4f50 X-Runtime: - - '0.012174' + - '0.081602' + Accept-Ranges: + - bytes + Date: + - Sat, 31 Oct 2020 02:48:20 GMT + Via: + - 1.1 varnish + X-Served-By: + - cache-fty21342-FTY + X-Cache: + - MISS + X-Cache-Hits: + - '0' + X-Timer: + - S1604112500.033752,VS0,VE144 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: - encoding: UTF-8 - string: '{"url":"https://appboy-data-export.s3.amazonaws.com/.zip","message":"success"}' - http_version: - recorded_at: Tue, 24 Mar 2015 17:33:20 GMT -recorded_with: VCR 2.9.2 + encoding: ASCII-8BIT + string: '{"object_prefix":"983b7b7b-e30e-4a8d-8a58-86807872eb9d-1604112500","url":"https://appboy-data-export.s3.amazonaws.com/OFR0gwchmOhqk5qlN530zg_nMbd_m9LYpZBgansMHP4.zip","message":"success"}' + recorded_at: Sat, 31 Oct 2020 02:48:20 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml b/spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml index 4798fcd..79e6374 100644 --- a/spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml +++ b/spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml @@ -2,13 +2,15 @@ http_interactions: - request: method: get - uri: https://api.appboy.com/segments/list?app_group_id= + uri: https://api.appboy.com/segments/list body: encoding: US-ASCII string: '' headers: + Authorization: + - Bearer User-Agent: - - Faraday v0.9.1 + - Faraday v1.1.0 Accept-Encoding: - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 Accept: @@ -18,41 +20,70 @@ http_interactions: code: 200 message: OK headers: - Server: - - nginx/1.6.2 - Date: - - Tue, 24 Mar 2015 17:02:25 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked Connection: - keep-alive - Status: - - 200 OK - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 - Etag: - - '"5f9d8fd4ccb0c6be554231c5db4a50ef"' + Content-Length: + - '879' Cache-Control: - max-age=0, private, must-revalidate + Content-Type: + - application/json + Etag: + - W/"2ca36d47d4a0ab6c97478ad8095f950d" + Server: + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + - max-age=31536000; includeSubDomains + X-Ratelimit-Limit: + - '250000' + X-Ratelimit-Remaining: + - '249964' + X-Ratelimit-Reset: + - '1604329200' X-Request-Id: - - c1d0235b282453da0401292810dab3a1 + - 79c11e09-ca04-4f47-8809-730e2255c0f8 X-Runtime: - - '0.011660' + - '0.017689' + Accept-Ranges: + - bytes + - bytes + Date: + - Mon, 02 Nov 2020 14:31:57 GMT + Via: + - 1.1 varnish + Age: + - '0' + X-Served-By: + - cache-fty21379-FTY + X-Cache: + - MISS + X-Cache-Hits: + - '0' + X-Timer: + - S1604327518.802705,VS0,VE79 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: - encoding: UTF-8 - string: '{"segments":[{"id":"","name":"test","analytics_tracking_enabled":false},{"id":"","name":"All - Users (Zweet Local - iOS)","analytics_tracking_enabled":true},{"id":"","name":"Engaged - Recent Users","analytics_tracking_enabled":true},{"id":"","name":"User - Onboarding - Second Week","analytics_tracking_enabled":true},{"id":"","name":"User - Onboarding - First Week","analytics_tracking_enabled":true},{"id":"","name":"Lapsed - Users - 30 days","analytics_tracking_enabled":true},{"id":"","name":"Lapsed - Users - 7 days","analytics_tracking_enabled":true}],"message":"success"}' - http_version: - recorded_at: Tue, 24 Mar 2015 17:02:25 GMT -recorded_with: VCR 2.9.2 + encoding: ASCII-8BIT + string: '{"segments":[{"id":"7ca29dd9-d4cc-4107-9fad-51db7dcf608a","name":"Lapsed + Users - 7 days","analytics_tracking_enabled":true,"tags":[]},{"id":"2917a7a8-f105-4e0e-9254-ee21453ea1d9","name":"Lapsed + Users - 30 days","analytics_tracking_enabled":true,"tags":[]},{"id":"550628b7-126c-4ebf-8967-0911ba1d344a","name":"User + Onboarding - First Week","analytics_tracking_enabled":true,"tags":[]},{"id":"6ea9b456-76ac-47af-b51f-cb0d5b894b2e","name":"User + Onboarding - Second Week","analytics_tracking_enabled":true,"tags":[]},{"id":"b77d057a-118c-442d-ad79-02a85a1d0ef7","name":"Engaged + Recent Users","analytics_tracking_enabled":true,"tags":[]},{"id":"5b54f222-360a-4640-91bc-908b7e7046d5","name":"All + Users (com.prebocorp.prebo - Android)","analytics_tracking_enabled":true,"tags":[]},{"id":"a4b4d6f0-5678-4857-81c4-8e12c8bf5708","name":"All + Users (Prebo - iOS)","analytics_tracking_enabled":true,"tags":[]},{"id":"23049c85-a290-401b-9c7a-b869560dca49","name":"All + Users (PreboStaging - Android)","analytics_tracking_enabled":true,"tags":[]},{"id":"6da4622f-d2f4-49b5-a5e3-3738a185fa92","name":"All + Users (PreboStaging - iOS)","analytics_tracking_enabled":true,"tags":[]},{"id":"d0dd12ba-da1a-43ef-94a2-5646ec846c5a","name":"test + sin registrados","analytics_tracking_enabled":false,"tags":[]},{"id":"9b460567-7e53-4abc-bacd-c1a765639805","name":"Male + 18-22","analytics_tracking_enabled":false,"tags":[]},{"id":"8e82374c-f312-4d04-a685-1281e943aabf","name":"Not + logged in user","analytics_tracking_enabled":false,"tags":[]},{"id":"d383da53-0f94-43cc-8421-cc165cf767bd","name":"Crear + unirme no apretado","analytics_tracking_enabled":false,"tags":[]},{"id":"b3f2caa2-0b06-4493-8aef-73e271b095ba","name":"chat","analytics_tracking_enabled":false,"tags":[]},{"id":"36d63ff0-bd15-40d4-a048-6bbe74053ae9","name":"rated + positive","analytics_tracking_enabled":false,"tags":[]},{"id":"a31a5d8c-0b8b-417e-bb56-47a388c92b01","name":"Groups + decreasing popularity","analytics_tracking_enabled":true,"tags":[]},{"id":"5ce49f49-d80e-4196-aa4f-481bfaf6d82b","name":"Shown + Groups","analytics_tracking_enabled":false,"tags":[]},{"id":"a7d33006-9c5d-4547-940d-c9e7bc24875b","name":"1 + month active","analytics_tracking_enabled":false,"tags":[]},{"id":"207cfa86-8697-440e-ae85-de7a299ec367","name":"suscribed + users","analytics_tracking_enabled":false,"tags":[]},{"id":"","name":"test-segment","analytics_tracking_enabled":false,"tags":[]}],"message":"success"}' + recorded_at: Mon, 02 Nov 2020 14:31:57 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/list_segments/with_success/responds_with_success.yml b/spec/fixtures/responses/list_segments/with_success/responds_with_success.yml index 97af067..7aa34fc 100644 --- a/spec/fixtures/responses/list_segments/with_success/responds_with_success.yml +++ b/spec/fixtures/responses/list_segments/with_success/responds_with_success.yml @@ -2,13 +2,15 @@ http_interactions: - request: method: get - uri: https://api.appboy.com/segments/list?app_group_id= + uri: https://api.appboy.com/segments/list body: encoding: US-ASCII string: '' headers: + Authorization: + - Bearer User-Agent: - - Faraday v0.9.1 + - Faraday v1.1.0 Accept-Encoding: - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 Accept: @@ -18,41 +20,67 @@ http_interactions: code: 200 message: OK headers: - Server: - - nginx/1.6.2 - Date: - - Tue, 24 Mar 2015 17:00:42 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked Connection: - keep-alive - Status: - - 200 OK - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 - Etag: - - '"5f9d8fd4ccb0c6be554231c5db4a50ef"' + Content-Length: + - '879' Cache-Control: - max-age=0, private, must-revalidate + Content-Type: + - application/json + Etag: + - W/"2ca36d47d4a0ab6c97478ad8095f950d" + Server: + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + - max-age=31536000; includeSubDomains + X-Ratelimit-Limit: + - '250000' + X-Ratelimit-Remaining: + - '249965' + X-Ratelimit-Reset: + - '1604329200' X-Request-Id: - - d46d80a0252ffe2f86ea5c5e11ce8650 + - 2e93141a-6dc3-45f0-a6c2-3b6b111a4d0d X-Runtime: - - '0.009647' + - '0.013175' + Accept-Ranges: + - bytes + Date: + - Mon, 02 Nov 2020 14:31:57 GMT + Via: + - 1.1 varnish + X-Served-By: + - cache-fty21336-FTY + X-Cache: + - MISS + X-Cache-Hits: + - '0' + X-Timer: + - S1604327517.931751,VS0,VE70 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: - encoding: UTF-8 - string: '{"segments":[{"id":"","name":"test","analytics_tracking_enabled":false},{"id":"","name":"All - Users (Zweet Local - iOS)","analytics_tracking_enabled":true},{"id":"","name":"Engaged - Recent Users","analytics_tracking_enabled":true},{"id":"","name":"User - Onboarding - Second Week","analytics_tracking_enabled":true},{"id":"","name":"User - Onboarding - First Week","analytics_tracking_enabled":true},{"id":"1","name":"Lapsed - Users - 30 days","analytics_tracking_enabled":true},{"id":"","name":"Lapsed - Users - 7 days","analytics_tracking_enabled":true}],"message":"success"}' - http_version: - recorded_at: Tue, 24 Mar 2015 17:00:42 GMT -recorded_with: VCR 2.9.2 + encoding: ASCII-8BIT + string: '{"segments":[{"id":"7ca29dd9-d4cc-4107-9fad-51db7dcf608a","name":"Lapsed + Users - 7 days","analytics_tracking_enabled":true,"tags":[]},{"id":"2917a7a8-f105-4e0e-9254-ee21453ea1d9","name":"Lapsed + Users - 30 days","analytics_tracking_enabled":true,"tags":[]},{"id":"550628b7-126c-4ebf-8967-0911ba1d344a","name":"User + Onboarding - First Week","analytics_tracking_enabled":true,"tags":[]},{"id":"6ea9b456-76ac-47af-b51f-cb0d5b894b2e","name":"User + Onboarding - Second Week","analytics_tracking_enabled":true,"tags":[]},{"id":"b77d057a-118c-442d-ad79-02a85a1d0ef7","name":"Engaged + Recent Users","analytics_tracking_enabled":true,"tags":[]},{"id":"5b54f222-360a-4640-91bc-908b7e7046d5","name":"All + Users (com.prebocorp.prebo - Android)","analytics_tracking_enabled":true,"tags":[]},{"id":"a4b4d6f0-5678-4857-81c4-8e12c8bf5708","name":"All + Users (Prebo - iOS)","analytics_tracking_enabled":true,"tags":[]},{"id":"23049c85-a290-401b-9c7a-b869560dca49","name":"All + Users (PreboStaging - Android)","analytics_tracking_enabled":true,"tags":[]},{"id":"6da4622f-d2f4-49b5-a5e3-3738a185fa92","name":"All + Users (PreboStaging - iOS)","analytics_tracking_enabled":true,"tags":[]},{"id":"d0dd12ba-da1a-43ef-94a2-5646ec846c5a","name":"test + sin registrados","analytics_tracking_enabled":false,"tags":[]},{"id":"9b460567-7e53-4abc-bacd-c1a765639805","name":"Male + 18-22","analytics_tracking_enabled":false,"tags":[]},{"id":"8e82374c-f312-4d04-a685-1281e943aabf","name":"Not + logged in user","analytics_tracking_enabled":false,"tags":[]},{"id":"d383da53-0f94-43cc-8421-cc165cf767bd","name":"Crear + unirme no apretado","analytics_tracking_enabled":false,"tags":[]},{"id":"b3f2caa2-0b06-4493-8aef-73e271b095ba","name":"chat","analytics_tracking_enabled":false,"tags":[]},{"id":"36d63ff0-bd15-40d4-a048-6bbe74053ae9","name":"rated + positive","analytics_tracking_enabled":false,"tags":[]},{"id":"a31a5d8c-0b8b-417e-bb56-47a388c92b01","name":"Groups + decreasing popularity","analytics_tracking_enabled":true,"tags":[]},{"id":"5ce49f49-d80e-4196-aa4f-481bfaf6d82b","name":"Shown + Groups","analytics_tracking_enabled":false,"tags":[]},{"id":"a7d33006-9c5d-4547-940d-c9e7bc24875b","name":"1 + month active","analytics_tracking_enabled":false,"tags":[]},{"id":"207cfa86-8697-440e-ae85-de7a299ec367","name":"suscribed + users","analytics_tracking_enabled":false,"tags":[]},{"id":"","name":"test-segment","analytics_tracking_enabled":false,"tags":[]}],"message":"success"}' + recorded_at: Mon, 02 Nov 2020 14:31:57 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/schedule_messages/unauthorized/responds_with_unauthorize.yml b/spec/fixtures/responses/schedule_messages/unauthorized/responds_with_unauthorize.yml index 71e8b7b..9624c8b 100644 --- a/spec/fixtures/responses/schedule_messages/unauthorized/responds_with_unauthorize.yml +++ b/spec/fixtures/responses/schedule_messages/unauthorized/responds_with_unauthorize.yml @@ -2,14 +2,15 @@ http_interactions: - request: method: post - uri: https://api.appboy.com/messages/schedule + uri: https://api.appboy.com/messages/schedule/create body: encoding: UTF-8 - string: '{"app_group_id":"non-existent","segment_ids":[""],"send_at":"2015-02-15 - 00:00:00 -0500","deliver_in_local_timezone":false,"messages":{"apple_push":{"alert":"hello"}}}' + string: '{"external_user_ids":[12345],"schedule":{"time":"2020-11-12T00:00:00+02:00","in_local_time":false},"messages":{"apple_push":{"alert":"hello"}}}' headers: + Authorization: + - Bearer non-existent User-Agent: - - Faraday v0.9.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -21,33 +22,46 @@ http_interactions: code: 401 message: Unauthorized headers: - Server: - - nginx/1.6.2 - Date: - - Mon, 16 Feb 2015 02:04:31 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked Connection: - keep-alive - Status: - - 401 Unauthorized - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 + Content-Length: + - '69' Cache-Control: - no-cache + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + X-Ratelimit-Limit: + - '' + X-Ratelimit-Remaining: + - '' + X-Ratelimit-Reset: + - '' X-Request-Id: - - 4fced4dccb4363e4660606ba27c2561a + - 3e02877e-9d07-47f9-b0e3-dde80ba00315 X-Runtime: - - '0.018142' + - '0.001179' + Accept-Ranges: + - bytes + Date: + - Mon, 02 Nov 2020 14:31:42 GMT + Via: + - 1.1 varnish + X-Served-By: + - cache-fty21369-FTY + X-Cache: + - MISS + X-Cache-Hits: + - '0' + X-Timer: + - S1604327502.092360,VS0,VE60 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: - encoding: UTF-8 - string: '{"message":"Invalid or missing App Group API Identifier: non-existent"}' - http_version: - recorded_at: Mon, 16 Feb 2015 02:04:31 GMT -recorded_with: VCR 2.9.2 + encoding: ASCII-8BIT + string: '{"message":"Invalid API key: non-existent"}' + recorded_at: Mon, 02 Nov 2020 14:31:42 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/schedule_messages/with_success/responds_with_created.yml b/spec/fixtures/responses/schedule_messages/with_success/responds_with_created.yml index 37ab610..78770f2 100644 --- a/spec/fixtures/responses/schedule_messages/with_success/responds_with_created.yml +++ b/spec/fixtures/responses/schedule_messages/with_success/responds_with_created.yml @@ -2,14 +2,15 @@ http_interactions: - request: method: post - uri: https://api.appboy.com/messages/schedule + uri: https://api.appboy.com/messages/schedule/create body: encoding: UTF-8 - string: '{"app_group_id":"","segment_ids":[""],"send_at":"2015-02-15 - 00:00:00 -0500","deliver_in_local_timezone":false,"messages":{"apple_push":{"alert":"hello"}}}' + string: '{"external_user_ids":[12345],"schedule":{"time":"2020-11-12T00:00:00+02:00","in_local_time":false},"messages":{"apple_push":{"alert":"hello"}}}' headers: + Authorization: + - Bearer User-Agent: - - Faraday v0.9.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -21,35 +22,49 @@ http_interactions: code: 201 message: Created headers: - Server: - - nginx/1.6.2 - Date: - - Mon, 16 Feb 2015 02:04:31 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked Connection: - keep-alive - Status: - - 201 Created - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 - Etag: - - '"8736cdfe08480bca66cffeee06268705"' + Content-Length: + - '128' Cache-Control: - max-age=0, private, must-revalidate + Content-Type: + - application/json + Etag: + - W/"8d88d739d491e3c704b11a6177731477" + Server: + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + - max-age=31536000; includeSubDomains + X-Ratelimit-Limit: + - '250000' + X-Ratelimit-Remaining: + - '249967' + X-Ratelimit-Reset: + - '1604329200' X-Request-Id: - - a66956f310c2c8d642746ea807a4d1a5 + - 951009c3-ed16-4c7e-a458-87ba79adee11 X-Runtime: - - '0.026183' + - '0.020109' + Accept-Ranges: + - bytes + Date: + - Mon, 02 Nov 2020 14:31:40 GMT + Via: + - 1.1 varnish + X-Served-By: + - cache-fty21328-FTY + X-Cache: + - MISS + X-Cache-Hits: + - '0' + X-Timer: + - S1604327500.399224,VS0,VE79 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: - encoding: UTF-8 - string: '{"message":"success"}' - http_version: - recorded_at: Mon, 16 Feb 2015 02:04:31 GMT -recorded_with: VCR 2.9.2 + encoding: ASCII-8BIT + string: '{"dispatch_id":"d1b053e8263e532c2c9349f3e4d77899","schedule_id":"09d8d8ff-2c6d-47df-9d14-90bba0096dac","message":"success"}' + recorded_at: Mon, 02 Nov 2020 14:31:40 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/schedule_messages/with_success/responds_with_success_message.yml b/spec/fixtures/responses/schedule_messages/with_success/responds_with_success_message.yml index 4283fc0..8297b48 100644 --- a/spec/fixtures/responses/schedule_messages/with_success/responds_with_success_message.yml +++ b/spec/fixtures/responses/schedule_messages/with_success/responds_with_success_message.yml @@ -2,14 +2,15 @@ http_interactions: - request: method: post - uri: https://api.appboy.com/messages/schedule + uri: https://api.appboy.com/messages/schedule/create body: encoding: UTF-8 - string: '{"app_group_id":"","segment_ids":[""],"send_at":"2015-02-15 - 00:00:00 -0500","deliver_in_local_timezone":false,"messages":{"apple_push":{"alert":"hello"}}}' + string: '{"external_user_ids":[12345],"schedule":{"time":"2020-11-12T00:00:00+02:00","in_local_time":false},"messages":{"apple_push":{"alert":"hello"}}}' headers: + Authorization: + - Bearer User-Agent: - - Faraday v0.9.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -21,35 +22,49 @@ http_interactions: code: 201 message: Created headers: - Server: - - nginx/1.6.2 - Date: - - Mon, 16 Feb 2015 02:04:31 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked Connection: - keep-alive - Status: - - 201 Created - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 - Etag: - - '"8736cdfe08480bca66cffeee06268705"' + Content-Length: + - '127' Cache-Control: - max-age=0, private, must-revalidate + Content-Type: + - application/json + Etag: + - W/"87c2f80d38369280c50ffca21dada755" + Server: + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + - max-age=31536000; includeSubDomains + X-Ratelimit-Limit: + - '250000' + X-Ratelimit-Remaining: + - '249966' + X-Ratelimit-Reset: + - '1604329200' X-Request-Id: - - 87445394eda38e6726c16d401e2ddd20 + - c79437de-0dfb-43f1-a80a-182d3e8f8b9f X-Runtime: - - '0.010460' + - '0.015951' + Accept-Ranges: + - bytes + Date: + - Mon, 02 Nov 2020 14:31:41 GMT + Via: + - 1.1 varnish + X-Served-By: + - cache-fty21341-FTY + X-Cache: + - MISS + X-Cache-Hits: + - '0' + X-Timer: + - S1604327501.236058,VS0,VE74 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: - encoding: UTF-8 - string: '{"message":"success"}' - http_version: - recorded_at: Mon, 16 Feb 2015 02:04:31 GMT -recorded_with: VCR 2.9.2 + encoding: ASCII-8BIT + string: '{"dispatch_id":"d58b0e1709fd4eeac774052ffbeb3b0c","schedule_id":"03d6230c-dc86-4db9-acb5-eabfecde64df","message":"success"}' + recorded_at: Mon, 02 Nov 2020 14:31:41 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/send_messages/unauthorized/responds_with_unauthorized.yml b/spec/fixtures/responses/send_messages/unauthorized/responds_with_unauthorized.yml index e47b9ba..b9ee428 100644 --- a/spec/fixtures/responses/send_messages/unauthorized/responds_with_unauthorized.yml +++ b/spec/fixtures/responses/send_messages/unauthorized/responds_with_unauthorized.yml @@ -5,10 +5,12 @@ http_interactions: uri: https://api.appboy.com/messages/send body: encoding: UTF-8 - string: '{"app_group_id":"non-existent","messages":{"apple_push":{"alert":"hello"}},"external_user_ids":[1],"segment_ids":[]}' + string: '{"messages":{"apple_push":{"alert":"hello"}},"external_user_ids":[1],"segment_ids":[]}' headers: + Authorization: + - Bearer non-existent User-Agent: - - Faraday v0.9.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -20,33 +22,46 @@ http_interactions: code: 401 message: Unauthorized headers: - Server: - - nginx/1.6.2 - Date: - - Mon, 16 Feb 2015 02:04:32 GMT + Connection: + - keep-alive + Content-Length: + - '69' + Cache-Control: + - no-cache Content-Type: - application/json - Transfer-Encoding: - - chunked - X-Cnection: - - close - Status: - - 401 Unauthorized + Server: + - nginx Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 - Cache-Control: - - no-cache + - max-age=0; includeSubDomains + X-Ratelimit-Limit: + - '' + X-Ratelimit-Remaining: + - '' + X-Ratelimit-Reset: + - '' X-Request-Id: - - 6084cafff4e655159039431f6fa925e7 + - 8c5b8f7d-db3c-418a-bff4-daed4f6a8685 X-Runtime: - - '0.017868' + - '0.001084' + Accept-Ranges: + - bytes + Date: + - Mon, 02 Nov 2020 14:59:11 GMT + Via: + - 1.1 varnish + X-Served-By: + - cache-pdk17871-PDK + X-Cache: + - MISS + X-Cache-Hits: + - '0' + X-Timer: + - S1604329152.688526,VS0,VE72 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: - encoding: UTF-8 - string: '{"message":"Invalid or missing App Group API Identifier: non-existent"}' - http_version: - recorded_at: Mon, 16 Feb 2015 02:04:32 GMT -recorded_with: VCR 2.9.2 + encoding: ASCII-8BIT + string: '{"message":"Invalid API key: non-existent"}' + recorded_at: Mon, 02 Nov 2020 14:59:11 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/send_messages/with_success/responds_with_created.yml b/spec/fixtures/responses/send_messages/with_success/responds_with_created.yml index 0a8d038..171b7f0 100644 --- a/spec/fixtures/responses/send_messages/with_success/responds_with_created.yml +++ b/spec/fixtures/responses/send_messages/with_success/responds_with_created.yml @@ -5,10 +5,12 @@ http_interactions: uri: https://api.appboy.com/messages/send body: encoding: UTF-8 - string: '{"app_group_id":"","messages":{"apple_push":{"alert":"hello"}},"external_user_ids":[1],"segment_ids":[]}' + string: '{"messages":{"apple_push":{"alert":"hello"}},"external_user_ids":[1],"segment_ids":[]}' headers: + Authorization: + - Bearer User-Agent: - - Faraday v0.9.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -20,35 +22,49 @@ http_interactions: code: 201 message: Created headers: - Server: - - nginx/1.6.2 - Date: - - Mon, 16 Feb 2015 02:04:32 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked Connection: - keep-alive - Status: - - 201 Created - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 - Etag: - - '"8736cdfe08480bca66cffeee06268705"' + Content-Length: + - '94' Cache-Control: - max-age=0, private, must-revalidate + Content-Type: + - application/json + Etag: + - W/"a14228c1f046b931d46bcda58c84a482" + Server: + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + - max-age=31536000; includeSubDomains + X-Ratelimit-Limit: + - '250000' + X-Ratelimit-Remaining: + - '249942' + X-Ratelimit-Reset: + - '1604329200' X-Request-Id: - - dafade35dada6bc0693c1e8b39153078 + - 78ae40ff-f122-495a-82aa-4293aabf888b X-Runtime: - - '0.007953' + - '0.017605' + Accept-Ranges: + - bytes + Date: + - Mon, 02 Nov 2020 14:59:09 GMT + Via: + - 1.1 varnish + X-Served-By: + - cache-pdk17835-PDK + X-Cache: + - MISS + X-Cache-Hits: + - '0' + X-Timer: + - S1604329149.197534,VS0,VE72 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: - encoding: UTF-8 - string: '{"message":"success"}' - http_version: - recorded_at: Mon, 16 Feb 2015 02:04:32 GMT -recorded_with: VCR 2.9.2 + encoding: ASCII-8BIT + string: '{"dispatch_id":"70ecab38a9cf947cb98ca134fb6a5c2c","message":"success"}' + recorded_at: Mon, 02 Nov 2020 14:59:09 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/send_messages/with_success/responds_with_success_message.yml b/spec/fixtures/responses/send_messages/with_success/responds_with_success_message.yml index a15907c..b5700e0 100644 --- a/spec/fixtures/responses/send_messages/with_success/responds_with_success_message.yml +++ b/spec/fixtures/responses/send_messages/with_success/responds_with_success_message.yml @@ -5,10 +5,12 @@ http_interactions: uri: https://api.appboy.com/messages/send body: encoding: UTF-8 - string: '{"app_group_id":"","messages":{"apple_push":{"alert":"hello"}},"external_user_ids":[1],"segment_ids":[]}' + string: '{"messages":{"apple_push":{"alert":"hello"}},"external_user_ids":[1],"segment_ids":[]}' headers: + Authorization: + - Bearer User-Agent: - - Faraday v0.9.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -20,35 +22,49 @@ http_interactions: code: 201 message: Created headers: - Server: - - nginx/1.6.2 - Date: - - Mon, 16 Feb 2015 02:04:32 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked Connection: - keep-alive - Status: - - 201 Created - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 - Etag: - - '"8736cdfe08480bca66cffeee06268705"' + Content-Length: + - '94' Cache-Control: - max-age=0, private, must-revalidate + Content-Type: + - application/json + Etag: + - W/"8a971cf64dc8fc1fe808397536b86f9b" + Server: + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + - max-age=31536000; includeSubDomains + X-Ratelimit-Limit: + - '250000' + X-Ratelimit-Remaining: + - '249941' + X-Ratelimit-Reset: + - '1604329200' X-Request-Id: - - f55537eeed57f01f6fa0a6aca87c23a0 + - 11228251-b4fa-4273-9039-9e948668dcf6 X-Runtime: - - '0.007894' + - '0.013324' + Accept-Ranges: + - bytes + Date: + - Mon, 02 Nov 2020 14:59:10 GMT + Via: + - 1.1 varnish + X-Served-By: + - cache-pdk17832-PDK + X-Cache: + - MISS + X-Cache-Hits: + - '0' + X-Timer: + - S1604329150.059926,VS0,VE69 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: - encoding: UTF-8 - string: '{"message":"success"}' - http_version: - recorded_at: Mon, 16 Feb 2015 02:04:32 GMT -recorded_with: VCR 2.9.2 + encoding: ASCII-8BIT + string: '{"dispatch_id":"e330e452b33475e7ef80c2360b06bea7","message":"success"}' + recorded_at: Mon, 02 Nov 2020 14:59:10 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/track_users/unauthorized/responds_with_unauthorized.yml b/spec/fixtures/responses/track_users/unauthorized/responds_with_unauthorized.yml index 2833035..8b61b59 100644 --- a/spec/fixtures/responses/track_users/unauthorized/responds_with_unauthorized.yml +++ b/spec/fixtures/responses/track_users/unauthorized/responds_with_unauthorized.yml @@ -5,12 +5,14 @@ http_interactions: uri: https://api.appboy.com/users/track body: encoding: UTF-8 - string: '{"app_group_id":"non-existent","attributes":[{"external_id":1,"foo":"bar"}],"events":[{"external_id":1,"name":"baz","time":"2015-02-15 + string: '{"attributes":[{"external_id":1,"foo":"bar"}],"events":[{"external_id":1,"name":"baz","time":"2015-02-15 00:00:00 -0500"}],"purchases":[{"external_id":1,"product_id":1,"time":"2015-02-15 00:00:00 -0500","currency":"CAD","price":1.0}]}' headers: + Authorization: + - Bearer non-existent User-Agent: - - Faraday v0.9.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -22,33 +24,46 @@ http_interactions: code: 401 message: Unauthorized headers: - Server: - - nginx/1.6.2 - Date: - - Mon, 16 Feb 2015 02:04:33 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked Connection: - keep-alive - Status: - - 401 Unauthorized - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 + Content-Length: + - '69' Cache-Control: - no-cache + Content-Type: + - application/json + Server: + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + X-Ratelimit-Limit: + - '' + X-Ratelimit-Remaining: + - '' + X-Ratelimit-Reset: + - '' X-Request-Id: - - e002507637bca77d75747d5ce4eb2eab + - ebb70512-0617-40a9-927d-3d5e1282c466 X-Runtime: - - '0.018230' + - '0.001265' + Accept-Ranges: + - bytes + Date: + - Sat, 31 Oct 2020 02:40:37 GMT + Via: + - 1.1 varnish + X-Served-By: + - cache-fty21371-FTY + X-Cache: + - MISS + X-Cache-Hits: + - '0' + X-Timer: + - S1604112037.128781,VS0,VE59 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: - encoding: UTF-8 - string: '{"message":"Invalid or missing App Group API Identifier: non-existent"}' - http_version: - recorded_at: Mon, 16 Feb 2015 02:04:33 GMT -recorded_with: VCR 2.9.2 + encoding: ASCII-8BIT + string: '{"message":"Invalid API key: non-existent"}' + recorded_at: Sat, 31 Oct 2020 02:40:37 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/track_users/with_success/responds_with_created.yml b/spec/fixtures/responses/track_users/with_success/responds_with_created.yml index 8c3fb9f..bd20959 100644 --- a/spec/fixtures/responses/track_users/with_success/responds_with_created.yml +++ b/spec/fixtures/responses/track_users/with_success/responds_with_created.yml @@ -5,12 +5,14 @@ http_interactions: uri: https://api.appboy.com/users/track body: encoding: UTF-8 - string: '{"app_group_id":"","attributes":[{"external_id":1,"foo":"bar"}],"events":[{"external_id":1,"name":"baz","time":"2015-02-15 + string: '{"attributes":[{"external_id":1,"foo":"bar"}],"events":[{"external_id":1,"name":"baz","time":"2015-02-15 00:00:00 -0500"}],"purchases":[{"external_id":1,"product_id":1,"time":"2015-02-15 00:00:00 -0500","currency":"CAD","price":1.0}]}' headers: + Authorization: + - Bearer User-Agent: - - Faraday v0.9.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -22,35 +24,49 @@ http_interactions: code: 201 message: Created headers: - Server: - - nginx/1.6.2 - Date: - - Mon, 16 Feb 2015 02:04:32 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked Connection: - keep-alive - Status: - - 201 Created - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 - Etag: - - '"79557eda34d1dfcacc80cdd626202b9a"' + Content-Length: + - '85' Cache-Control: - max-age=0, private, must-revalidate + Content-Type: + - application/json + Etag: + - W/"68b326343749fed4d6cc5dda395b5367" + Server: + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + - max-age=31536000; includeSubDomains + X-Ratelimit-Limit: + - '250000' + X-Ratelimit-Remaining: + - '250000' + X-Ratelimit-Reset: + - '1604113200' X-Request-Id: - - 68c4d37952f3f900cd83820409e74696 + - 845ca2aa-8f2f-4c6d-b508-75ac6d0ef4e0 X-Runtime: - - '0.008458' + - '0.017891' + Accept-Ranges: + - bytes + Date: + - Sat, 31 Oct 2020 02:40:35 GMT + Via: + - 1.1 varnish + X-Served-By: + - cache-fty21361-FTY + X-Cache: + - MISS + X-Cache-Hits: + - '0' + X-Timer: + - S1604112035.430586,VS0,VE79 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: - encoding: UTF-8 + encoding: ASCII-8BIT string: '{"attributes_processed":1,"events_processed":1,"purchases_processed":1,"message":"success"}' - http_version: - recorded_at: Mon, 16 Feb 2015 02:04:32 GMT -recorded_with: VCR 2.9.2 + recorded_at: Sat, 31 Oct 2020 02:40:35 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/fixtures/responses/track_users/with_success/responds_with_success_message.yml b/spec/fixtures/responses/track_users/with_success/responds_with_success_message.yml index 30db8aa..9f7357e 100644 --- a/spec/fixtures/responses/track_users/with_success/responds_with_success_message.yml +++ b/spec/fixtures/responses/track_users/with_success/responds_with_success_message.yml @@ -5,12 +5,14 @@ http_interactions: uri: https://api.appboy.com/users/track body: encoding: UTF-8 - string: '{"app_group_id":"","attributes":[{"external_id":1,"foo":"bar"}],"events":[{"external_id":1,"name":"baz","time":"2015-02-15 + string: '{"attributes":[{"external_id":1,"foo":"bar"}],"events":[{"external_id":1,"name":"baz","time":"2015-02-15 00:00:00 -0500"}],"purchases":[{"external_id":1,"product_id":1,"time":"2015-02-15 00:00:00 -0500","currency":"CAD","price":1.0}]}' headers: + Authorization: + - Bearer User-Agent: - - Faraday v0.9.1 + - Faraday v1.1.0 Content-Type: - application/json Accept-Encoding: @@ -22,35 +24,49 @@ http_interactions: code: 201 message: Created headers: - Server: - - nginx/1.6.2 - Date: - - Mon, 16 Feb 2015 02:04:33 GMT - Content-Type: - - application/json - Transfer-Encoding: - - chunked Connection: - keep-alive - Status: - - 201 Created - Strict-Transport-Security: - - max-age=31536000 - X-Ua-Compatible: - - IE=Edge,chrome=1 - Etag: - - '"79557eda34d1dfcacc80cdd626202b9a"' + Content-Length: + - '85' Cache-Control: - max-age=0, private, must-revalidate + Content-Type: + - application/json + Etag: + - W/"68b326343749fed4d6cc5dda395b5367" + Server: + - nginx + Strict-Transport-Security: + - max-age=0; includeSubDomains + - max-age=31536000; includeSubDomains + X-Ratelimit-Limit: + - '250000' + X-Ratelimit-Remaining: + - '250000' + X-Ratelimit-Reset: + - '1604113200' X-Request-Id: - - 5a25265723e1309578e13dc0d22e6edb + - 9e452ae4-714d-4a3b-9d30-c07d7b14a61d X-Runtime: - - '0.007930' + - '0.009051' + Accept-Ranges: + - bytes + Date: + - Sat, 31 Oct 2020 02:40:36 GMT + Via: + - 1.1 varnish + X-Served-By: + - cache-fty21355-FTY + X-Cache: + - MISS + X-Cache-Hits: + - '0' + X-Timer: + - S1604112036.305804,VS0,VE68 Vary: - - Accept-Encoding + - Origin,Accept-Encoding body: - encoding: UTF-8 + encoding: ASCII-8BIT string: '{"attributes_processed":1,"events_processed":1,"purchases_processed":1,"message":"success"}' - http_version: - recorded_at: Mon, 16 Feb 2015 02:04:32 GMT -recorded_with: VCR 2.9.2 + recorded_at: Sat, 31 Oct 2020 02:40:36 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/integrations/delete_users_spec.rb b/spec/integrations/delete_users_spec.rb index 3d0e38d..4d5e570 100644 --- a/spec/integrations/delete_users_spec.rb +++ b/spec/integrations/delete_users_spec.rb @@ -21,7 +21,7 @@ end context 'unauthorized', vcr: true do - let(:app_group_id) { 'non-existent' } + let(:api_key) { 'non-existent' } it 'responds with unauthorized' do expect(delete_users.status).to be 401 diff --git a/spec/integrations/email_status_spec.rb b/spec/integrations/email_status_spec.rb index 5b63790..db56ad6 100644 --- a/spec/integrations/email_status_spec.rb +++ b/spec/integrations/email_status_spec.rb @@ -19,18 +19,4 @@ ) end end - - context 'unknown email', vcr: true do - let(:email) { 'doesntexist@example.com' } - - it 'responds with bad request' do - expect(subject.status).to be 400 - end - - it 'responds with error message' do - expect(JSON.parse(subject.body)).to eq( - 'message' => 'There is no user with the provided email' - ) - end - end end diff --git a/spec/integrations/list_segments_spec.rb b/spec/integrations/list_segments_spec.rb index 25b1ffb..765e046 100644 --- a/spec/integrations/list_segments_spec.rb +++ b/spec/integrations/list_segments_spec.rb @@ -9,9 +9,9 @@ end it 'responds with a list of segments' do - expect(segments.count).to be 7 + expect(segments.count).to be > 0 - expect(segments.first['name']).to eq 'test' + expect(segments.first['name']).not_to be_empty end def segments diff --git a/spec/integrations/schedule_messages_spec.rb b/spec/integrations/schedule_messages_spec.rb index 1b90e59..7894ebb 100644 --- a/spec/integrations/schedule_messages_spec.rb +++ b/spec/integrations/schedule_messages_spec.rb @@ -1,12 +1,13 @@ require 'spec_helper' describe 'schedule messages' do - let(:user_ids) { [1] } + let(:user_ids) { [12345] } + let(:test_time) { "2020-11-12T00:00:00+02:00" } let(:messages) { build(:messages) } subject(:schedule_messages) do - api.schedule_messages(send_at: test_time, - messages: messages, segment_id: segment_id) + api.schedule_messages(time: test_time, + messages: messages, external_user_ids: user_ids) end context 'with success', vcr: true do @@ -15,14 +16,14 @@ end it 'responds with success message' do - expect(JSON.parse(schedule_messages.body)).to eq( + expect(JSON.parse(schedule_messages.body)).to include( 'message' => 'success' ) end end context 'unauthorized', vcr: true do - let(:app_group_id) { 'non-existent' } + let(:api_key) { 'non-existent' } it 'responds with unauthorize' do expect(schedule_messages.status).to be 401 diff --git a/spec/integrations/send_messages_spec.rb b/spec/integrations/send_messages_spec.rb index c2cf1c7..856be2d 100644 --- a/spec/integrations/send_messages_spec.rb +++ b/spec/integrations/send_messages_spec.rb @@ -14,14 +14,14 @@ end it 'responds with success message' do - expect(JSON.parse(send_messages.body)).to eq( + expect(JSON.parse(send_messages.body)).to include( 'message' => 'success' ) end end context 'unauthorized', vcr: true do - let(:app_group_id) { 'non-existent' } + let(:api_key) { 'non-existent' } it 'responds with unauthorized' do expect(send_messages.status).to be 401 diff --git a/spec/integrations/track_users_spec.rb b/spec/integrations/track_users_spec.rb index b700f83..1e17a08 100644 --- a/spec/integrations/track_users_spec.rb +++ b/spec/integrations/track_users_spec.rb @@ -26,7 +26,7 @@ end context 'unauthorized', vcr: true do - let(:app_group_id) { 'non-existent' } + let(:api_key) { 'non-existent' } it 'responds with unauthorized' do expect(track_users.status).to be 401 diff --git a/spec/support/integrations.rb b/spec/support/integrations.rb index 6ea9371..8132171 100644 --- a/spec/support/integrations.rb +++ b/spec/support/integrations.rb @@ -4,13 +4,9 @@ module Integrations extend ActiveSupport::Concern included do - let(:app_group_id) { ENV.fetch('APPBOY_GROUP_ID') } + let(:api_key) { ENV.fetch('APPBOY_API_KEY') } let(:segment_id) { ENV.fetch('APPBOY_TEST_SEGMENT') } - - let(:api) { Appboy::API.new(app_group_id) } - - - + let(:api) { Appboy::API.new(api_key) } end RSpec.configure do |config| diff --git a/spec/support/vcr.rb b/spec/support/vcr.rb index 2bd02b9..3952504 100644 --- a/spec/support/vcr.rb +++ b/spec/support/vcr.rb @@ -1,7 +1,7 @@ require 'vcr' VCR.configure do |config| - config.filter_sensitive_data('') { ENV.fetch('APPBOY_GROUP_ID') } + config.filter_sensitive_data('') { ENV.fetch('APPBOY_API_KEY') } config.filter_sensitive_data('') { ENV.fetch('APPBOY_TEST_SEGMENT') } config.cassette_library_dir = 'spec/fixtures/responses'