braze_ruby 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +157 -0
  7. data/Rakefile +1 -0
  8. data/braze_ruby.gemspec +33 -0
  9. data/lib/braze_ruby.rb +9 -0
  10. data/lib/braze_ruby/api.rb +31 -0
  11. data/lib/braze_ruby/deprecated.rb +19 -0
  12. data/lib/braze_ruby/endpoints.rb +4 -0
  13. data/lib/braze_ruby/endpoints/email_status.rb +13 -0
  14. data/lib/braze_ruby/endpoints/schedule_messages.rb +15 -0
  15. data/lib/braze_ruby/endpoints/send_messages.rb +15 -0
  16. data/lib/braze_ruby/endpoints/track_users.rb +29 -0
  17. data/lib/braze_ruby/http.rb +30 -0
  18. data/lib/braze_ruby/rest.rb +7 -0
  19. data/lib/braze_ruby/rest/base.rb +19 -0
  20. data/lib/braze_ruby/rest/email_status.rb +22 -0
  21. data/lib/braze_ruby/rest/export_users.rb +27 -0
  22. data/lib/braze_ruby/rest/list_segments.rb +11 -0
  23. data/lib/braze_ruby/rest/schedule_messages.rb +28 -0
  24. data/lib/braze_ruby/rest/send_messages.rb +22 -0
  25. data/lib/braze_ruby/rest/track_users.rb +14 -0
  26. data/lib/braze_ruby/version.rb +3 -0
  27. data/spec/braze_ruby/api_spec.rb +4 -0
  28. data/spec/braze_ruby/endpoints/track_users_spec.rb +72 -0
  29. data/spec/braze_ruby/rest/email_status_spec.rb +19 -0
  30. data/spec/braze_ruby/rest/export_users_spec.rb +19 -0
  31. data/spec/braze_ruby/rest/schedule_messages_spec.rb +36 -0
  32. data/spec/braze_ruby/rest/send_messages_spec.rb +33 -0
  33. data/spec/braze_ruby/rest/track_users_spec.rb +24 -0
  34. data/spec/factories.rb +36 -0
  35. data/spec/fixtures/responses/email_status/existing_email/responds_with_created.yml +69 -0
  36. data/spec/fixtures/responses/email_status/existing_email/responds_with_success_message.yml +69 -0
  37. data/spec/fixtures/responses/email_status/unknown_email/responds_with_bad_request.yml +69 -0
  38. data/spec/fixtures/responses/email_status/unknown_email/responds_with_success_message.yml +69 -0
  39. data/spec/fixtures/responses/export_users/by_ids/with_success/responds_with_created.yml +69 -0
  40. data/spec/fixtures/responses/export_users/by_segment/with_success/responds_with_created.yml +69 -0
  41. data/spec/fixtures/responses/list_segments/with_success/responds_with_a_list_of_segments.yml +81 -0
  42. data/spec/fixtures/responses/list_segments/with_success/responds_with_success.yml +81 -0
  43. data/spec/fixtures/responses/schedule_messages/unauthorized/responds_with_unauthorize.yml +67 -0
  44. data/spec/fixtures/responses/schedule_messages/with_success/responds_with_created.yml +70 -0
  45. data/spec/fixtures/responses/schedule_messages/with_success/responds_with_success_message.yml +70 -0
  46. data/spec/fixtures/responses/send_messages/unauthorized/responds_with_unauthorized.yml +66 -0
  47. data/spec/fixtures/responses/send_messages/with_success/responds_with_created.yml +69 -0
  48. data/spec/fixtures/responses/send_messages/with_success/responds_with_success_message.yml +69 -0
  49. data/spec/fixtures/responses/track_users/unauthorized/responds_with_unauthorized.yml +68 -0
  50. data/spec/fixtures/responses/track_users/with_success/responds_with_created.yml +71 -0
  51. data/spec/fixtures/responses/track_users/with_success/responds_with_success_message.yml +71 -0
  52. data/spec/integrations/email_status_spec.rb +36 -0
  53. data/spec/integrations/export_users_spec.rb +27 -0
  54. data/spec/integrations/list_segments_spec.rb +19 -0
  55. data/spec/integrations/schedule_messages_spec.rb +31 -0
  56. data/spec/integrations/send_messages_spec.rb +30 -0
  57. data/spec/integrations/track_users_spec.rb +35 -0
  58. data/spec/spec_helper.rb +29 -0
  59. data/spec/support/factory_bot.rb +10 -0
  60. data/spec/support/integrations.rb +20 -0
  61. data/spec/support/vcr.rb +16 -0
  62. metadata +312 -0
@@ -0,0 +1,67 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/messages/schedule/create"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"api_key":"non-existent","external_user_ids":[1],"schedule":{"time":"2019-02-15
9
+ 00:00:00 -0500","in_local_time":false},"messages":{"apple_push":{"alert":"hello"}}}'
10
+ headers:
11
+ User-Agent:
12
+ - Faraday v0.14.0
13
+ Content-Type:
14
+ - application/json
15
+ Accept-Encoding:
16
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
17
+ Accept:
18
+ - "*/*"
19
+ response:
20
+ status:
21
+ code: 401
22
+ message: Unauthorized
23
+ headers:
24
+ Cache-Control:
25
+ - no-cache
26
+ Content-Type:
27
+ - application/json
28
+ Server:
29
+ - nginx
30
+ Strict-Transport-Security:
31
+ - max-age=0; includeSubDomains
32
+ X-Ratelimit-Limit:
33
+ - ''
34
+ X-Ratelimit-Remaining:
35
+ - ''
36
+ X-Ratelimit-Reset:
37
+ - ''
38
+ X-Request-Id:
39
+ - 34c2cbbd-02bb-4104-9c06-47cb08bd061c
40
+ X-Runtime:
41
+ - '0.008932'
42
+ Content-Length:
43
+ - '85'
44
+ Accept-Ranges:
45
+ - bytes
46
+ Date:
47
+ - Tue, 17 Apr 2018 21:08:21 GMT
48
+ Via:
49
+ - 1.1 varnish
50
+ Connection:
51
+ - keep-alive
52
+ X-Served-By:
53
+ - cache-pdk17829-PDK
54
+ X-Cache:
55
+ - MISS
56
+ X-Cache-Hits:
57
+ - '0'
58
+ X-Timer:
59
+ - S1523999302.620925,VS0,VE191
60
+ Vary:
61
+ - Accept-Encoding
62
+ body:
63
+ encoding: ASCII-8BIT
64
+ string: '{"message":"Invalid App Group API Identifier: non-existent"}'
65
+ http_version:
66
+ recorded_at: Tue, 17 Apr 2018 21:08:21 GMT
67
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,70 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/messages/schedule/create"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"api_key":"<BRAZE_REST_API_KEY>","external_user_ids":[1],"schedule":{"time":"2019-02-15
9
+ 00:00:00 -0500","in_local_time":false},"messages":{"apple_push":{"alert":"hello"}}}'
10
+ headers:
11
+ User-Agent:
12
+ - Faraday v0.14.0
13
+ Content-Type:
14
+ - application/json
15
+ Accept-Encoding:
16
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
17
+ Accept:
18
+ - "*/*"
19
+ response:
20
+ status:
21
+ code: 201
22
+ message: Created
23
+ headers:
24
+ Cache-Control:
25
+ - max-age=0, private, must-revalidate
26
+ Content-Type:
27
+ - application/json
28
+ Etag:
29
+ - W/"f9913a2616a9d19ab2dafed53b6ac0cd"
30
+ Server:
31
+ - nginx
32
+ Strict-Transport-Security:
33
+ - max-age=0; includeSubDomains
34
+ - max-age=31536000; includeSubDomains
35
+ X-Ratelimit-Limit:
36
+ - '50000'
37
+ X-Ratelimit-Remaining:
38
+ - '49991'
39
+ X-Ratelimit-Reset:
40
+ - '1524002400'
41
+ X-Request-Id:
42
+ - fd1ed05b-89a1-4419-8402-34599af22c88
43
+ X-Runtime:
44
+ - '0.029549'
45
+ Content-Length:
46
+ - '96'
47
+ Accept-Ranges:
48
+ - bytes
49
+ Date:
50
+ - Tue, 17 Apr 2018 21:08:21 GMT
51
+ Via:
52
+ - 1.1 varnish
53
+ Connection:
54
+ - keep-alive
55
+ X-Served-By:
56
+ - cache-pdk17849-PDK
57
+ X-Cache:
58
+ - MISS
59
+ X-Cache-Hits:
60
+ - '0'
61
+ X-Timer:
62
+ - S1523999301.065052,VS0,VE210
63
+ Vary:
64
+ - Accept-Encoding
65
+ body:
66
+ encoding: ASCII-8BIT
67
+ string: '{"schedule_id":"db90f8dc-2ef3-420f-a4b0-c08605acc21f","message":"success"}'
68
+ http_version:
69
+ recorded_at: Tue, 17 Apr 2018 21:08:21 GMT
70
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,70 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/messages/schedule/create"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"api_key":"<BRAZE_REST_API_KEY>","external_user_ids":[1],"schedule":{"time":"2019-02-15
9
+ 00:00:00 -0500","in_local_time":false},"messages":{"apple_push":{"alert":"hello"}}}'
10
+ headers:
11
+ User-Agent:
12
+ - Faraday v0.14.0
13
+ Content-Type:
14
+ - application/json
15
+ Accept-Encoding:
16
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
17
+ Accept:
18
+ - "*/*"
19
+ response:
20
+ status:
21
+ code: 201
22
+ message: Created
23
+ headers:
24
+ Cache-Control:
25
+ - max-age=0, private, must-revalidate
26
+ Content-Type:
27
+ - application/json
28
+ Etag:
29
+ - W/"28a09ecfebb2ce520ec4eb59271fe82b"
30
+ Server:
31
+ - nginx
32
+ Strict-Transport-Security:
33
+ - max-age=0; includeSubDomains
34
+ - max-age=31536000; includeSubDomains
35
+ X-Ratelimit-Limit:
36
+ - '50000'
37
+ X-Ratelimit-Remaining:
38
+ - '49990'
39
+ X-Ratelimit-Reset:
40
+ - '1524002400'
41
+ X-Request-Id:
42
+ - c55b095e-a19a-45d9-bb3d-1203b0c85b69
43
+ X-Runtime:
44
+ - '0.017538'
45
+ Content-Length:
46
+ - '98'
47
+ Accept-Ranges:
48
+ - bytes
49
+ Date:
50
+ - Tue, 17 Apr 2018 21:08:21 GMT
51
+ Via:
52
+ - 1.1 varnish
53
+ Connection:
54
+ - keep-alive
55
+ X-Served-By:
56
+ - cache-pdk17831-PDK
57
+ X-Cache:
58
+ - MISS
59
+ X-Cache-Hits:
60
+ - '0'
61
+ X-Timer:
62
+ - S1523999301.354059,VS0,VE199
63
+ Vary:
64
+ - Accept-Encoding
65
+ body:
66
+ encoding: ASCII-8BIT
67
+ string: '{"schedule_id":"31d4c1d9-d784-4218-abee-c95e03a30f03","message":"success"}'
68
+ http_version:
69
+ recorded_at: Tue, 17 Apr 2018 21:08:21 GMT
70
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,66 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/messages/send"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"api_key":"non-existent","messages":{"apple_push":{"alert":"hello"}},"external_user_ids":[1]}'
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
+ - b9f8ce77-4265-46a4-8010-04dad0d35c92
39
+ X-Runtime:
40
+ - '0.006126'
41
+ Content-Length:
42
+ - '85'
43
+ Accept-Ranges:
44
+ - bytes
45
+ Date:
46
+ - Tue, 17 Apr 2018 21:08:23 GMT
47
+ Via:
48
+ - 1.1 varnish
49
+ Connection:
50
+ - keep-alive
51
+ X-Served-By:
52
+ - cache-pdk17839-PDK
53
+ X-Cache:
54
+ - MISS
55
+ X-Cache-Hits:
56
+ - '0'
57
+ X-Timer:
58
+ - S1523999303.988243,VS0,VE44
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: Tue, 17 Apr 2018 21:08:23 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>/messages/send"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"api_key":"<BRAZE_REST_API_KEY>","messages":{"apple_push":{"alert":"hello"}},"external_user_ids":[1]}'
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/"838a7c62adda8d131d694ae13ba2c5b7"
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
+ - '49989'
38
+ X-Ratelimit-Reset:
39
+ - '1524002400'
40
+ X-Request-Id:
41
+ - aec47065-45d4-4fb7-a593-a4ffd110c314
42
+ X-Runtime:
43
+ - '0.013801'
44
+ Content-Length:
45
+ - '46'
46
+ Accept-Ranges:
47
+ - bytes
48
+ Date:
49
+ - Tue, 17 Apr 2018 21:08:22 GMT
50
+ Via:
51
+ - 1.1 varnish
52
+ Connection:
53
+ - keep-alive
54
+ X-Served-By:
55
+ - cache-pdk17821-PDK
56
+ X-Cache:
57
+ - MISS
58
+ X-Cache-Hits:
59
+ - '0'
60
+ X-Timer:
61
+ - S1523999302.923924,VS0,VE423
62
+ Vary:
63
+ - Accept-Encoding
64
+ body:
65
+ encoding: ASCII-8BIT
66
+ string: '{"message":"success"}'
67
+ http_version:
68
+ recorded_at: Tue, 17 Apr 2018 21:08:22 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>/messages/send"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"api_key":"<BRAZE_REST_API_KEY>","messages":{"apple_push":{"alert":"hello"}},"external_user_ids":[1]}'
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/"838a7c62adda8d131d694ae13ba2c5b7"
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
+ - '1524002400'
40
+ X-Request-Id:
41
+ - 864641c8-44d3-4389-84a1-e411ee44561e
42
+ X-Runtime:
43
+ - '0.027612'
44
+ Content-Length:
45
+ - '46'
46
+ Accept-Ranges:
47
+ - bytes
48
+ Date:
49
+ - Tue, 17 Apr 2018 21:08:22 GMT
50
+ Via:
51
+ - 1.1 varnish
52
+ Connection:
53
+ - keep-alive
54
+ X-Served-By:
55
+ - cache-pdk17839-PDK
56
+ X-Cache:
57
+ - MISS
58
+ X-Cache-Hits:
59
+ - '0'
60
+ X-Timer:
61
+ - S1523999302.411567,VS0,VE410
62
+ Vary:
63
+ - Accept-Encoding
64
+ body:
65
+ encoding: ASCII-8BIT
66
+ string: '{"message":"success"}'
67
+ http_version:
68
+ recorded_at: Tue, 17 Apr 2018 21:08:22 GMT
69
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,68 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: "<BRAZE_REST_URL>/users/track"
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"api_key":"non-existent","attributes":[{"external_id":1,"foo":"bar"}],"events":[{"external_id":1,"name":"baz","time":"2019-02-15
9
+ 00:00:00 -0500"}],"purchases":[{"external_id":1,"product_id":1,"time":"2019-02-15
10
+ 00:00:00 -0500","currency":"CAD","price":1.0}]}'
11
+ headers:
12
+ User-Agent:
13
+ - Faraday v0.14.0
14
+ Content-Type:
15
+ - application/json
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 401
23
+ message: Unauthorized
24
+ headers:
25
+ Cache-Control:
26
+ - no-cache
27
+ Content-Type:
28
+ - application/json
29
+ Server:
30
+ - nginx
31
+ Strict-Transport-Security:
32
+ - max-age=0; includeSubDomains
33
+ X-Ratelimit-Limit:
34
+ - '0'
35
+ X-Ratelimit-Remaining:
36
+ - '0'
37
+ X-Ratelimit-Reset:
38
+ - '1524002400'
39
+ X-Request-Id:
40
+ - 7089825e-0390-4b95-b471-3c096e1df0e6
41
+ X-Runtime:
42
+ - '0.006623'
43
+ Content-Length:
44
+ - '85'
45
+ Accept-Ranges:
46
+ - bytes
47
+ Date:
48
+ - Tue, 17 Apr 2018 21:08:08 GMT
49
+ Via:
50
+ - 1.1 varnish
51
+ Connection:
52
+ - keep-alive
53
+ X-Served-By:
54
+ - cache-pdk17844-PDK
55
+ X-Cache:
56
+ - MISS
57
+ X-Cache-Hits:
58
+ - '0'
59
+ X-Timer:
60
+ - S1523999288.903112,VS0,VE193
61
+ Vary:
62
+ - Accept-Encoding
63
+ body:
64
+ encoding: ASCII-8BIT
65
+ string: '{"message":"Invalid App Group API Identifier: non-existent"}'
66
+ http_version:
67
+ recorded_at: Tue, 17 Apr 2018 21:08:08 GMT
68
+ recorded_with: VCR 4.0.0