braze_ruby 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e78db383c73ab0375f4c015ce0f99d17e7ed7035
4
- data.tar.gz: c5d7efa4e531f247e114288e2afbba7e3f6107ec
2
+ SHA256:
3
+ metadata.gz: 04567c2148da9db982023a103156347777831203d442829a8b7b24f25df2f3b6
4
+ data.tar.gz: f6e48e092c5edb9d11d5e4a962c5cd181eeb108eb297f4321086943d890a96ee
5
5
  SHA512:
6
- metadata.gz: 7400b2b2035c80486acd34dfbe77fbde74c8a56f7afc7837e9a4e773a9f636ac13d94de054dc709a040dfd5195bfc92b5534f5ad4b1108a6a85dfb909c4e1788
7
- data.tar.gz: 1a575b9c132c8a1489bf8e9fa873dc2175ee158fd1eb05f70793872f0a9c35ebd4324f4d197ede7ba383e8194116272da9c0f4032156562fd78e6ba017dffc05
6
+ metadata.gz: 24284d239f84699ac674e0becb5c7e1b5207c7e7f4954f06a1d4aa8f40cf54842e074aae97f595a3a5918f6aa06c4bade387e67efc08951e0e8a9221bdedaea4
7
+ data.tar.gz: 0fd11acad7ed6ad7e4940336bbb82556d0cf2a91c2532a73f7e41e07e01fb89591d10670a82c757c0f5f55b93fdadd22271d3bf8dc433b1135eb6f9a9b69911b
data/.gitignore CHANGED
@@ -5,7 +5,6 @@
5
5
  .yardoc
6
6
  .ruby-version
7
7
  .env
8
- Gemfile.lock
9
8
  InstalledFiles
10
9
  _yardoc
11
10
  coverage
@@ -0,0 +1,79 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ braze_ruby (0.1.0)
5
+ faraday
6
+ faraday_middleware
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (5.2.3)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ addressable (2.6.0)
17
+ public_suffix (>= 2.0.2, < 4.0)
18
+ coderay (1.1.2)
19
+ concurrent-ruby (1.1.5)
20
+ crack (0.4.3)
21
+ safe_yaml (~> 1.0.0)
22
+ diff-lcs (1.3)
23
+ dotenv (2.7.2)
24
+ factory_bot (5.0.2)
25
+ activesupport (>= 4.2.0)
26
+ faraday (0.15.4)
27
+ multipart-post (>= 1.2, < 3)
28
+ faraday_middleware (0.13.1)
29
+ faraday (>= 0.7.4, < 1.0)
30
+ hashdiff (0.3.8)
31
+ i18n (1.6.0)
32
+ concurrent-ruby (~> 1.0)
33
+ method_source (0.9.2)
34
+ minitest (5.11.3)
35
+ multipart-post (2.0.0)
36
+ pry (0.12.2)
37
+ coderay (~> 1.1.0)
38
+ method_source (~> 0.9.0)
39
+ public_suffix (3.0.3)
40
+ rake (12.3.2)
41
+ rspec (3.8.0)
42
+ rspec-core (~> 3.8.0)
43
+ rspec-expectations (~> 3.8.0)
44
+ rspec-mocks (~> 3.8.0)
45
+ rspec-core (3.8.0)
46
+ rspec-support (~> 3.8.0)
47
+ rspec-expectations (3.8.2)
48
+ diff-lcs (>= 1.2.0, < 2.0)
49
+ rspec-support (~> 3.8.0)
50
+ rspec-mocks (3.8.0)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.8.0)
53
+ rspec-support (3.8.0)
54
+ safe_yaml (1.0.5)
55
+ thread_safe (0.3.6)
56
+ tzinfo (1.2.5)
57
+ thread_safe (~> 0.1)
58
+ vcr (4.0.0)
59
+ webmock (3.5.1)
60
+ addressable (>= 2.3.6)
61
+ crack (>= 0.3.2)
62
+ hashdiff
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ braze_ruby!
69
+ bundler (>= 1.3)
70
+ dotenv
71
+ factory_bot
72
+ pry
73
+ rake
74
+ rspec
75
+ vcr
76
+ webmock
77
+
78
+ BUNDLED WITH
79
+ 2.0.1
data/Rakefile CHANGED
@@ -1 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task default: :spec
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = %w(josh@godynamo.com hugo@godynamo.com justin.boltz@takl.com)
11
11
  spec.description = %q{Braze wrapper}
12
12
  spec.summary = %q{A wrapper for the Braze REST API forked from the appboy gem, track users/events/purchases, send & schedule messages}
13
- spec.homepage = 'http://braze.com'
13
+ spec.homepage = 'https://www.braze.com/'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -18,16 +18,14 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'virtus'
22
21
  spec.add_dependency 'faraday'
23
22
  spec.add_dependency 'faraday_middleware'
24
- spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'bundler', '>= 1.3'
25
24
  spec.add_development_dependency 'rake'
26
25
  spec.add_development_dependency 'rspec'
27
26
  spec.add_development_dependency 'dotenv'
28
27
  spec.add_development_dependency 'vcr'
29
28
  spec.add_development_dependency 'webmock'
30
29
  spec.add_development_dependency 'pry'
31
- spec.add_development_dependency 'activesupport'
32
30
  spec.add_development_dependency 'factory_bot'
33
31
  end
@@ -1,5 +1,3 @@
1
- require 'json'
2
- require 'virtus'
3
1
  require 'braze_ruby/version'
4
2
 
5
3
  module BrazeRuby
@@ -3,6 +3,7 @@ require 'braze_ruby/endpoints/track_users'
3
3
  require 'braze_ruby/endpoints/send_messages'
4
4
  require 'braze_ruby/endpoints/schedule_messages'
5
5
  require 'braze_ruby/endpoints/email_status'
6
+ require 'braze_ruby/endpoints/email_sync'
6
7
  require 'braze_ruby/endpoints/delete_users'
7
8
 
8
9
  module BrazeRuby
@@ -13,6 +14,7 @@ module BrazeRuby
13
14
  include BrazeRuby::Endpoints::SendMessages
14
15
  include BrazeRuby::Endpoints::ScheduleMessages
15
16
  include BrazeRuby::Endpoints::EmailStatus
17
+ include BrazeRuby::Endpoints::EmailSync
16
18
  include BrazeRuby::Endpoints::DeleteUsers
17
19
 
18
20
  def export_users(**payload)
@@ -1,4 +1,5 @@
1
1
  require 'braze_ruby/endpoints/email_status'
2
+ require 'braze_ruby/endpoints/email_sync'
2
3
  require 'braze_ruby/endpoints/schedule_messages'
3
4
  require 'braze_ruby/endpoints/send_messages'
4
5
  require 'braze_ruby/endpoints/track_users'
@@ -0,0 +1,13 @@
1
+ module BrazeRuby
2
+ module Endpoints
3
+ module EmailSync
4
+ def email_unsubscribes(**payload)
5
+ BrazeRuby::REST::EmailUnsubscribes.new(api_key, braze_url, payload).perform
6
+ end
7
+
8
+ def email_hard_bounces(**payload)
9
+ BrazeRuby::REST::EmailHardBounces.new(api_key, braze_url, payload).perform
10
+ end
11
+ end
12
+ end
13
+ end
@@ -3,6 +3,8 @@ require 'braze_ruby/rest/track_users'
3
3
  require 'braze_ruby/rest/send_messages'
4
4
  require 'braze_ruby/rest/schedule_messages'
5
5
  require 'braze_ruby/rest/email_status'
6
+ require 'braze_ruby/rest/email_hard_bounces'
7
+ require 'braze_ruby/rest/email_unsubscribes'
6
8
  require 'braze_ruby/rest/export_users'
7
9
  require 'braze_ruby/rest/list_segments'
8
10
  require 'braze_ruby/rest/delete_users'
@@ -0,0 +1,20 @@
1
+ module BrazeRuby
2
+ module REST
3
+ class EmailHardBounces < Base
4
+ attr_reader :api_key, :params
5
+
6
+ def initialize(api_key, braze_url, **params)
7
+ @api_key = api_key
8
+ @params = params
9
+ super braze_url
10
+ end
11
+
12
+ def perform
13
+ http.get('/email/hard_bounces', {
14
+ 'api_key': api_key,
15
+ **@params
16
+ })
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module BrazeRuby
2
+ module REST
3
+ class EmailUnsubscribes < Base
4
+ attr_reader :api_key, :params
5
+
6
+ def initialize(api_key, braze_url, **params)
7
+ @api_key = api_key
8
+ @params = params
9
+ super braze_url
10
+ end
11
+
12
+ def perform
13
+ http.get('/email/unsubscribes', {
14
+ 'api_key': api_key,
15
+ **params
16
+ })
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,3 +1,3 @@
1
1
  module BrazeRuby
2
- VERSION = '0.0.2'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ class API
4
+ include BrazeRuby::Endpoints::DeleteUsers
5
+
6
+ def api_key
7
+ :api_key
8
+ end
9
+ end
10
+
11
+ describe BrazeRuby::Endpoints::DeleteUsers do
12
+ let(:api) { API.new }
13
+ let(:delete_users_service) { double(:delete_users_service) }
14
+
15
+ before { api.delete_users_service = delete_users_service }
16
+
17
+ describe '#delete_users' do
18
+ let(:payload) { [1, 2, 3] }
19
+
20
+ subject(:delete_users!) { api.delete_users(payload) }
21
+
22
+ it 'deletes users' do
23
+ expect(delete_users_service).to receive(:perform)
24
+ .with(:api_key, external_ids: payload)
25
+
26
+ delete_users!
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe BrazeRuby::REST::DeleteUsers do
4
+ let(:http) { double(:http) }
5
+
6
+ let(:payload) { {external_ids: [1, 2, 3]} }
7
+
8
+ let(:api_key) { :api_key }
9
+
10
+ subject { described_class.new :rest_url}
11
+
12
+ before { subject.http = http }
13
+
14
+ it 'makes an http call to the delete user endpoint' do
15
+ expect(http).to receive(:post).with '/users/delete',
16
+ payload.merge({ api_key: :api_key })
17
+
18
+ subject.perform(api_key, payload)
19
+ end
20
+ end
@@ -1,35 +1,35 @@
1
1
  FactoryBot.define do
2
2
  factory :attribute, class: Hash do
3
3
  skip_create
4
- external_id 1
5
- foo :bar
4
+ external_id { 1 }
5
+ foo { :bar }
6
6
 
7
7
  initialize_with { attributes }
8
8
  end
9
9
 
10
10
  factory :event, class: Hash do
11
11
  skip_create
12
- external_id 1
13
- name :baz
14
- time Time.now
12
+ external_id { 1 }
13
+ name { :baz }
14
+ time { Time.now }
15
15
 
16
16
  initialize_with { attributes }
17
17
  end
18
18
 
19
19
  factory :purchase, class: Hash do
20
20
  skip_create
21
- external_id 1
22
- product_id 1
23
- time Time.now
24
- currency 'CAD'
25
- price 1.0
21
+ external_id { 1 }
22
+ product_id { 1 }
23
+ time { Time.now }
24
+ currency { 'CAD' }
25
+ price { 1.0 }
26
26
 
27
27
  initialize_with { attributes }
28
28
  end
29
29
 
30
30
  factory :messages, class: Hash do
31
31
  skip_create
32
- apple_push({ alert: :hello })
32
+ apple_push { {alert: :hello} }
33
33
 
34
34
  initialize_with { attributes }
35
35
  end
@@ -0,0 +1,66 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/delete"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"api_key":"non-existent","external_ids":[400,401,402]}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.14.0
12
+ Content-Type:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 401
21
+ message: Unauthorized
22
+ headers:
23
+ Cache-Control:
24
+ - no-cache
25
+ Content-Type:
26
+ - application/json
27
+ Server:
28
+ - nginx
29
+ Strict-Transport-Security:
30
+ - max-age=0; includeSubDomains
31
+ X-Ratelimit-Limit:
32
+ - ''
33
+ X-Ratelimit-Remaining:
34
+ - ''
35
+ X-Ratelimit-Reset:
36
+ - ''
37
+ X-Request-Id:
38
+ - bd4c1e19-8065-4db0-b5e5-aaafcb40ef9d
39
+ X-Runtime:
40
+ - '0.011342'
41
+ Content-Length:
42
+ - '85'
43
+ Accept-Ranges:
44
+ - bytes
45
+ Date:
46
+ - Fri, 18 May 2018 18:54:32 GMT
47
+ Via:
48
+ - 1.1 varnish
49
+ Connection:
50
+ - keep-alive
51
+ X-Served-By:
52
+ - cache-pdk17824-PDK
53
+ X-Cache:
54
+ - MISS
55
+ X-Cache-Hits:
56
+ - '0'
57
+ X-Timer:
58
+ - S1526669672.332248,VS0,VE196
59
+ Vary:
60
+ - Accept-Encoding
61
+ body:
62
+ encoding: ASCII-8BIT
63
+ string: '{"message":"Invalid App Group API Identifier: non-existent"}'
64
+ http_version:
65
+ recorded_at: Fri, 18 May 2018 18:54:14 GMT
66
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,69 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/delete"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"api_key":"<BRAZE_REST_API_KEY>","external_ids":[400,401,402]}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.14.0
12
+ Content-Type:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 201
21
+ message: Created
22
+ headers:
23
+ Cache-Control:
24
+ - max-age=0, private, must-revalidate
25
+ Content-Type:
26
+ - application/json
27
+ Etag:
28
+ - W/"383e14c9bc8f36ee9f92221ad86557aa"
29
+ Server:
30
+ - nginx
31
+ Strict-Transport-Security:
32
+ - max-age=0; includeSubDomains
33
+ - max-age=31536000; includeSubDomains
34
+ X-Ratelimit-Limit:
35
+ - '50000'
36
+ X-Ratelimit-Remaining:
37
+ - '49988'
38
+ X-Ratelimit-Reset:
39
+ - '1526670000'
40
+ X-Request-Id:
41
+ - 3c706f21-aef5-4527-ab35-ded3437dbb58
42
+ X-Runtime:
43
+ - '0.019468'
44
+ Content-Length:
45
+ - '89'
46
+ Accept-Ranges:
47
+ - bytes
48
+ Date:
49
+ - Fri, 18 May 2018 18:54:31 GMT
50
+ Via:
51
+ - 1.1 varnish
52
+ Connection:
53
+ - keep-alive
54
+ X-Served-By:
55
+ - cache-atl6224-ATL
56
+ X-Cache:
57
+ - MISS
58
+ X-Cache-Hits:
59
+ - '0'
60
+ X-Timer:
61
+ - S1526669672.735390,VS0,VE223
62
+ Vary:
63
+ - Accept-Encoding
64
+ body:
65
+ encoding: ASCII-8BIT
66
+ string: '{"invalid_user_ids":[400,401,402],"deleted":3,"message":"success"}'
67
+ http_version:
68
+ recorded_at: Fri, 18 May 2018 18:54:13 GMT
69
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,69 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/delete"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"api_key":"<BRAZE_REST_API_KEY>","external_ids":[400,401,402]}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.14.0
12
+ Content-Type:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 201
21
+ message: Created
22
+ headers:
23
+ Cache-Control:
24
+ - max-age=0, private, must-revalidate
25
+ Content-Type:
26
+ - application/json
27
+ Etag:
28
+ - W/"05c5a9339e57ae2f67e0aeb4404dbe22"
29
+ Server:
30
+ - nginx
31
+ Strict-Transport-Security:
32
+ - max-age=0; includeSubDomains
33
+ - max-age=31536000; includeSubDomains
34
+ X-Ratelimit-Limit:
35
+ - '50000'
36
+ X-Ratelimit-Remaining:
37
+ - '49987'
38
+ X-Ratelimit-Reset:
39
+ - '1526670000'
40
+ X-Request-Id:
41
+ - 51543cb0-651c-49ea-aaba-ca8350e763bd
42
+ X-Runtime:
43
+ - '0.011310'
44
+ Content-Length:
45
+ - '89'
46
+ Accept-Ranges:
47
+ - bytes
48
+ Date:
49
+ - Fri, 18 May 2018 18:54:32 GMT
50
+ Via:
51
+ - 1.1 varnish
52
+ Connection:
53
+ - keep-alive
54
+ X-Served-By:
55
+ - cache-atl6222-ATL
56
+ X-Cache:
57
+ - MISS
58
+ X-Cache-Hits:
59
+ - '0'
60
+ X-Timer:
61
+ - S1526669672.051288,VS0,VE215
62
+ Vary:
63
+ - Accept-Encoding
64
+ body:
65
+ encoding: ASCII-8BIT
66
+ string: '{"invalid_user_ids":[400,401,402],"deleted":0,"message":"success"}'
67
+ http_version:
68
+ recorded_at: Fri, 18 May 2018 18:54:14 GMT
69
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,71 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: "<BRAZE_REST_URL>/email/hard_bounces?api_key=<BRAZE_REST_API_KEY>&end_date=2019-02-25&start_date=2019-02-20"
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.4
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Cache-Control:
22
+ - max-age=0, private, must-revalidate
23
+ Content-Type:
24
+ - application/json
25
+ Etag:
26
+ - W/"b0a253ed9e9eda7c79a0df7a6f87381f"
27
+ Server:
28
+ - nginx
29
+ Strict-Transport-Security:
30
+ - max-age=0; includeSubDomains
31
+ - max-age=31536000; includeSubDomains
32
+ X-Ratelimit-Limit:
33
+ - '250000'
34
+ X-Ratelimit-Remaining:
35
+ - '249995'
36
+ X-Ratelimit-Reset:
37
+ - '1553594400'
38
+ X-Request-Id:
39
+ - 5dc096d8-4a70-4bf7-9ec6-b824f8fb67cc
40
+ X-Runtime:
41
+ - '0.094331'
42
+ Accept-Ranges:
43
+ - bytes
44
+ - bytes
45
+ Age:
46
+ - '0'
47
+ - '0'
48
+ Content-Length:
49
+ - '58'
50
+ Date:
51
+ - Tue, 26 Mar 2019 09:53:46 GMT
52
+ Via:
53
+ - 1.1 varnish
54
+ Connection:
55
+ - keep-alive
56
+ X-Served-By:
57
+ - cache-ams21041-AMS
58
+ X-Cache:
59
+ - MISS
60
+ X-Cache-Hits:
61
+ - '0'
62
+ X-Timer:
63
+ - S1553594027.657238,VS0,VE105
64
+ Vary:
65
+ - Accept-Encoding
66
+ body:
67
+ encoding: ASCII-8BIT
68
+ string: '{"emails":[],"message":"success"}'
69
+ http_version:
70
+ recorded_at: Tue, 26 Mar 2019 09:53:46 GMT
71
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,71 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: "<BRAZE_REST_URL>/email/unsubscribes?api_key=<BRAZE_REST_API_KEY>&end_date=2019-02-25&start_date=2019-02-20"
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.4
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Cache-Control:
22
+ - max-age=0, private, must-revalidate
23
+ Content-Type:
24
+ - application/json
25
+ Etag:
26
+ - W/"b0a253ed9e9eda7c79a0df7a6f87381f"
27
+ Server:
28
+ - nginx
29
+ Strict-Transport-Security:
30
+ - max-age=0; includeSubDomains
31
+ - max-age=31536000; includeSubDomains
32
+ X-Ratelimit-Limit:
33
+ - '250000'
34
+ X-Ratelimit-Remaining:
35
+ - '249996'
36
+ X-Ratelimit-Reset:
37
+ - '1553594400'
38
+ X-Request-Id:
39
+ - c3dec26e-ab23-4812-ad5d-0f817df5804d
40
+ X-Runtime:
41
+ - '0.112126'
42
+ Accept-Ranges:
43
+ - bytes
44
+ - bytes
45
+ Age:
46
+ - '0'
47
+ - '0'
48
+ Content-Length:
49
+ - '58'
50
+ Date:
51
+ - Tue, 26 Mar 2019 09:49:52 GMT
52
+ Via:
53
+ - 1.1 varnish
54
+ Connection:
55
+ - keep-alive
56
+ X-Served-By:
57
+ - cache-ams21023-AMS
58
+ X-Cache:
59
+ - MISS
60
+ X-Cache-Hits:
61
+ - '0'
62
+ X-Timer:
63
+ - S1553593792.986450,VS0,VE124
64
+ Vary:
65
+ - Accept-Encoding
66
+ body:
67
+ encoding: ASCII-8BIT
68
+ string: '{"emails":[],"message":"success"}'
69
+ http_version:
70
+ recorded_at: Tue, 26 Mar 2019 09:49:52 GMT
71
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,72 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: "<BRAZE_REST_URL>/email/unsubscribes?api_key=<BRAZE_REST_API_KEY>&end_date=2019-03-25&start_date=2019-03-20"
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.4
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Cache-Control:
22
+ - max-age=0, private, must-revalidate
23
+ Content-Type:
24
+ - application/json
25
+ Etag:
26
+ - W/"5eb0e9bcc8119b72a7bccb6a7195558f"
27
+ Server:
28
+ - nginx
29
+ Strict-Transport-Security:
30
+ - max-age=0; includeSubDomains
31
+ - max-age=31536000; includeSubDomains
32
+ X-Ratelimit-Limit:
33
+ - '250000'
34
+ X-Ratelimit-Remaining:
35
+ - '249997'
36
+ X-Ratelimit-Reset:
37
+ - '1553594400'
38
+ X-Request-Id:
39
+ - 40b96604-9ef6-4a50-a322-e0ddb27b9d57
40
+ X-Runtime:
41
+ - '0.221463'
42
+ Accept-Ranges:
43
+ - bytes
44
+ - bytes
45
+ Age:
46
+ - '0'
47
+ - '0'
48
+ Content-Length:
49
+ - '128'
50
+ Date:
51
+ - Tue, 26 Mar 2019 09:48:45 GMT
52
+ Via:
53
+ - 1.1 varnish
54
+ Connection:
55
+ - keep-alive
56
+ X-Served-By:
57
+ - cache-ams21030-AMS
58
+ X-Cache:
59
+ - MISS
60
+ X-Cache-Hits:
61
+ - '0'
62
+ X-Timer:
63
+ - S1553593725.060211,VS0,VE233
64
+ Vary:
65
+ - Accept-Encoding
66
+ body:
67
+ encoding: ASCII-8BIT
68
+ string: '{"emails":[{"email":"wojtek@test.com","unsubscribed_at":"2019-03-21
69
+ 16:31:31 +0000"}],"message":"success"}'
70
+ http_version:
71
+ recorded_at: Tue, 26 Mar 2019 09:48:45 GMT
72
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'delete users' do
4
+ let(:external_ids) { [400, 401, 402] }
5
+
6
+ subject(:delete_users) do
7
+ api.delete_users(external_ids)
8
+ end
9
+
10
+ context 'with success', vcr: true do
11
+ it 'responds with created' do
12
+ expect(delete_users.status).to be 201
13
+ end
14
+
15
+ it 'responds with success message' do
16
+ expect(JSON.parse(delete_users.body)).to include(
17
+ 'message' => 'success'
18
+ )
19
+ end
20
+ end
21
+
22
+ context 'unauthorized', vcr: true do
23
+ let(:api_key) { 'non-existent' }
24
+
25
+ it 'responds with unauthorized' do
26
+ expect(delete_users.status).to be 401
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'email sync' do
4
+ describe 'unsubscribes' do
5
+ it 'responds with unsubscribed emails', vcr: true do
6
+ response = api.email_unsubscribes(start_date: '2019-03-20', end_date: '2019-03-25')
7
+ emails = JSON.parse(response.body)['emails']
8
+
9
+ expect(emails.size).to eq(1)
10
+ expect(emails.first['email']).to eq('wojtek@test.com')
11
+ end
12
+
13
+ it 'responds with empty array when no unsubscribes', vcr: true do
14
+ response = api.email_unsubscribes(start_date: '2019-02-20', end_date: '2019-02-25')
15
+ emails = JSON.parse(response.body)['emails']
16
+
17
+ expect(emails.size).to eq(0)
18
+ end
19
+ end
20
+
21
+ describe 'hard_bounces' do
22
+ it 'responds with empty array when no hard bounces', vcr: true do
23
+ response = api.email_hard_bounces(start_date: '2019-02-20', end_date: '2019-02-25')
24
+ emails = JSON.parse(response.body)['emails']
25
+
26
+ expect(emails.size).to eq(0)
27
+ end
28
+ end
29
+ end
@@ -1,8 +1,7 @@
1
+ require 'bundler/setup'
1
2
  require 'pry'
2
3
  require 'dotenv'
3
- require 'bundler/setup'
4
4
 
5
- Bundler.setup
6
5
  Dotenv.load
7
6
 
8
7
  require 'braze_ruby'
@@ -10,17 +9,20 @@ require 'support/vcr'
10
9
  require 'support/factory_bot'
11
10
  require 'support/integrations'
12
11
 
12
+ BRAZE_REST_API_KEY = ENV.fetch('BRAZE_REST_API_KEY', 'test')
13
+ BRAZE_REST_URL = ENV.fetch('BRAZE_REST_URL', 'https://rest.iad-03.braze.com')
14
+
13
15
  RSpec.configure do |config|
14
16
  def test_time
15
17
  Time.parse('2019-02-15 00:00:00 -0500')
16
18
  end
17
19
 
18
20
  def braze_rest_api_key
19
- 'test'
21
+ BRAZE_REST_API_KEY
20
22
  end
21
23
 
22
24
  def braze_rest_url
23
- 'https://rest.iad-03.braze.com'
25
+ BRAZE_REST_URL
24
26
  end
25
27
 
26
28
  def braze_test_segment
@@ -1,10 +1,10 @@
1
1
  require 'factory_bot'
2
- require 'factories'
3
2
 
4
3
  RSpec.configure do |config|
5
4
  config.include FactoryBot::Syntax::Methods
6
5
 
7
6
  config.before(:suite) do
7
+ FactoryBot.find_definitions
8
8
  FactoryBot.lint
9
9
  end
10
10
  end
@@ -1,17 +1,18 @@
1
- require 'active_support/concern'
2
-
3
1
  module Integrations
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- let(:api_key) { braze_rest_api_key }
8
- let(:rest_url) { braze_rest_url }
9
- let(:segment_id) { braze_test_segment }
10
-
11
- let(:api) { BrazeRuby::API.new(api_key, rest_url) }
2
+ def api_key
3
+ braze_rest_api_key
4
+ end
12
5
 
6
+ def rest_url
7
+ braze_rest_url
8
+ end
13
9
 
10
+ def segment_id
11
+ braze_test_segment
12
+ end
14
13
 
14
+ def api
15
+ BrazeRuby::API.new(api_key, rest_url)
15
16
  end
16
17
 
17
18
  RSpec.configure do |config|
@@ -1,8 +1,8 @@
1
1
  require 'vcr'
2
2
 
3
3
  VCR.configure do |config|
4
- config.filter_sensitive_data('<BRAZE_REST_API_KEY>') { ENV.fetch('BRAZE_REST_API_KEY') }
5
- config.filter_sensitive_data('<BRAZE_REST_URL>') { ENV.fetch('BRAZE_REST_URL')}
4
+ config.filter_sensitive_data('<BRAZE_REST_API_KEY>') { BRAZE_REST_API_KEY }
5
+ config.filter_sensitive_data('<BRAZE_REST_URL>') { BRAZE_REST_URL }
6
6
 
7
7
  config.cassette_library_dir = 'spec/fixtures/responses'
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: braze_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Nussbaum
@@ -10,22 +10,8 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-05-18 00:00:00.000000000 Z
13
+ date: 2019-04-04 00:00:00.000000000 Z
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: virtus
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - ">="
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- version: '0'
29
15
  - !ruby/object:Gem::Dependency
30
16
  name: faraday
31
17
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +44,14 @@ dependencies:
58
44
  name: bundler
59
45
  requirement: !ruby/object:Gem::Requirement
60
46
  requirements:
61
- - - "~>"
47
+ - - ">="
62
48
  - !ruby/object:Gem::Version
63
49
  version: '1.3'
64
50
  type: :development
65
51
  prerelease: false
66
52
  version_requirements: !ruby/object:Gem::Requirement
67
53
  requirements:
68
- - - "~>"
54
+ - - ">="
69
55
  - !ruby/object:Gem::Version
70
56
  version: '1.3'
71
57
  - !ruby/object:Gem::Dependency
@@ -152,20 +138,6 @@ dependencies:
152
138
  - - ">="
153
139
  - !ruby/object:Gem::Version
154
140
  version: '0'
155
- - !ruby/object:Gem::Dependency
156
- name: activesupport
157
- requirement: !ruby/object:Gem::Requirement
158
- requirements:
159
- - - ">="
160
- - !ruby/object:Gem::Version
161
- version: '0'
162
- type: :development
163
- prerelease: false
164
- version_requirements: !ruby/object:Gem::Requirement
165
- requirements:
166
- - - ">="
167
- - !ruby/object:Gem::Version
168
- version: '0'
169
141
  - !ruby/object:Gem::Dependency
170
142
  name: factory_bot
171
143
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +164,7 @@ files:
192
164
  - ".gitignore"
193
165
  - ".rspec"
194
166
  - Gemfile
167
+ - Gemfile.lock
195
168
  - LICENSE.txt
196
169
  - README.md
197
170
  - Rakefile
@@ -202,6 +175,7 @@ files:
202
175
  - lib/braze_ruby/endpoints.rb
203
176
  - lib/braze_ruby/endpoints/delete_users.rb
204
177
  - lib/braze_ruby/endpoints/email_status.rb
178
+ - lib/braze_ruby/endpoints/email_sync.rb
205
179
  - lib/braze_ruby/endpoints/schedule_messages.rb
206
180
  - lib/braze_ruby/endpoints/send_messages.rb
207
181
  - lib/braze_ruby/endpoints/track_users.rb
@@ -209,7 +183,9 @@ files:
209
183
  - lib/braze_ruby/rest.rb
210
184
  - lib/braze_ruby/rest/base.rb
211
185
  - lib/braze_ruby/rest/delete_users.rb
186
+ - lib/braze_ruby/rest/email_hard_bounces.rb
212
187
  - lib/braze_ruby/rest/email_status.rb
188
+ - lib/braze_ruby/rest/email_unsubscribes.rb
213
189
  - lib/braze_ruby/rest/export_users.rb
214
190
  - lib/braze_ruby/rest/list_segments.rb
215
191
  - lib/braze_ruby/rest/schedule_messages.rb
@@ -217,17 +193,25 @@ files:
217
193
  - lib/braze_ruby/rest/track_users.rb
218
194
  - lib/braze_ruby/version.rb
219
195
  - spec/braze_ruby/api_spec.rb
196
+ - spec/braze_ruby/endpoints/delete_users_spec.rb
220
197
  - spec/braze_ruby/endpoints/track_users_spec.rb
198
+ - spec/braze_ruby/rest/delete_users_spec.rb
221
199
  - spec/braze_ruby/rest/email_status_spec.rb
222
200
  - spec/braze_ruby/rest/export_users_spec.rb
223
201
  - spec/braze_ruby/rest/schedule_messages_spec.rb
224
202
  - spec/braze_ruby/rest/send_messages_spec.rb
225
203
  - spec/braze_ruby/rest/track_users_spec.rb
226
204
  - spec/factories.rb
205
+ - spec/fixtures/responses/delete_users/unauthorized/responds_with_unauthorized.yml
206
+ - spec/fixtures/responses/delete_users/with_success/responds_with_created.yml
207
+ - spec/fixtures/responses/delete_users/with_success/responds_with_success_message.yml
227
208
  - spec/fixtures/responses/email_status/existing_email/responds_with_created.yml
228
209
  - spec/fixtures/responses/email_status/existing_email/responds_with_success_message.yml
229
210
  - spec/fixtures/responses/email_status/unknown_email/responds_with_bad_request.yml
230
211
  - spec/fixtures/responses/email_status/unknown_email/responds_with_success_message.yml
212
+ - spec/fixtures/responses/email_sync/hard_bounces/responds_with_empty_array_when_no_hard_bounces.yml
213
+ - spec/fixtures/responses/email_sync/unsubscribes/responds_with_empty_array_when_no_unsubscribes.yml
214
+ - spec/fixtures/responses/email_sync/unsubscribes/responds_with_unsubscribed_emails.yml
231
215
  - spec/fixtures/responses/export_users/by_ids/with_success/responds_with_created.yml
232
216
  - spec/fixtures/responses/export_users/by_segment/with_success/responds_with_created.yml
233
217
  - spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml
@@ -241,7 +225,9 @@ files:
241
225
  - spec/fixtures/responses/track_users/unauthorized/responds_with_unauthorized.yml
242
226
  - spec/fixtures/responses/track_users/with_success/responds_with_created.yml
243
227
  - spec/fixtures/responses/track_users/with_success/responds_with_success_message.yml
228
+ - spec/integrations/delete_users_spec.rb
244
229
  - spec/integrations/email_status_spec.rb
230
+ - spec/integrations/email_sync_spec.rb
245
231
  - spec/integrations/export_users_spec.rb
246
232
  - spec/integrations/list_segments_spec.rb
247
233
  - spec/integrations/schedule_messages_spec.rb
@@ -251,7 +237,7 @@ files:
251
237
  - spec/support/factory_bot.rb
252
238
  - spec/support/integrations.rb
253
239
  - spec/support/vcr.rb
254
- homepage: http://braze.com
240
+ homepage: https://www.braze.com/
255
241
  licenses:
256
242
  - MIT
257
243
  metadata: {}
@@ -270,25 +256,32 @@ required_rubygems_version: !ruby/object:Gem::Requirement
270
256
  - !ruby/object:Gem::Version
271
257
  version: '0'
272
258
  requirements: []
273
- rubyforge_project:
274
- rubygems_version: 2.6.13
259
+ rubygems_version: 3.0.3
275
260
  signing_key:
276
261
  specification_version: 4
277
262
  summary: A wrapper for the Braze REST API forked from the appboy gem, track users/events/purchases,
278
263
  send & schedule messages
279
264
  test_files:
280
265
  - spec/braze_ruby/api_spec.rb
266
+ - spec/braze_ruby/endpoints/delete_users_spec.rb
281
267
  - spec/braze_ruby/endpoints/track_users_spec.rb
268
+ - spec/braze_ruby/rest/delete_users_spec.rb
282
269
  - spec/braze_ruby/rest/email_status_spec.rb
283
270
  - spec/braze_ruby/rest/export_users_spec.rb
284
271
  - spec/braze_ruby/rest/schedule_messages_spec.rb
285
272
  - spec/braze_ruby/rest/send_messages_spec.rb
286
273
  - spec/braze_ruby/rest/track_users_spec.rb
287
274
  - spec/factories.rb
275
+ - spec/fixtures/responses/delete_users/unauthorized/responds_with_unauthorized.yml
276
+ - spec/fixtures/responses/delete_users/with_success/responds_with_created.yml
277
+ - spec/fixtures/responses/delete_users/with_success/responds_with_success_message.yml
288
278
  - spec/fixtures/responses/email_status/existing_email/responds_with_created.yml
289
279
  - spec/fixtures/responses/email_status/existing_email/responds_with_success_message.yml
290
280
  - spec/fixtures/responses/email_status/unknown_email/responds_with_bad_request.yml
291
281
  - spec/fixtures/responses/email_status/unknown_email/responds_with_success_message.yml
282
+ - spec/fixtures/responses/email_sync/hard_bounces/responds_with_empty_array_when_no_hard_bounces.yml
283
+ - spec/fixtures/responses/email_sync/unsubscribes/responds_with_empty_array_when_no_unsubscribes.yml
284
+ - spec/fixtures/responses/email_sync/unsubscribes/responds_with_unsubscribed_emails.yml
292
285
  - spec/fixtures/responses/export_users/by_ids/with_success/responds_with_created.yml
293
286
  - spec/fixtures/responses/export_users/by_segment/with_success/responds_with_created.yml
294
287
  - spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml
@@ -302,7 +295,9 @@ test_files:
302
295
  - spec/fixtures/responses/track_users/unauthorized/responds_with_unauthorized.yml
303
296
  - spec/fixtures/responses/track_users/with_success/responds_with_created.yml
304
297
  - spec/fixtures/responses/track_users/with_success/responds_with_success_message.yml
298
+ - spec/integrations/delete_users_spec.rb
305
299
  - spec/integrations/email_status_spec.rb
300
+ - spec/integrations/email_sync_spec.rb
306
301
  - spec/integrations/export_users_spec.rb
307
302
  - spec/integrations/list_segments_spec.rb
308
303
  - spec/integrations/schedule_messages_spec.rb