clever_tap 0.3.0

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 (59) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +48 -0
  5. data/.travis.yml +6 -0
  6. data/Gemfile +16 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +164 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +8 -0
  11. data/bin/setup +8 -0
  12. data/clever_tap.gemspec +33 -0
  13. data/lib/clever_tap.rb +79 -0
  14. data/lib/clever_tap/client.rb +113 -0
  15. data/lib/clever_tap/config.rb +25 -0
  16. data/lib/clever_tap/entity.rb +87 -0
  17. data/lib/clever_tap/event.rb +30 -0
  18. data/lib/clever_tap/failed_response.rb +28 -0
  19. data/lib/clever_tap/profile.rb +7 -0
  20. data/lib/clever_tap/response.rb +28 -0
  21. data/lib/clever_tap/successful_response.rb +30 -0
  22. data/lib/clever_tap/uploader.rb +72 -0
  23. data/lib/clever_tap/version.rb +3 -0
  24. data/lib/clevertap-ruby.rb +1 -0
  25. data/spec/factories/profile.rb +36 -0
  26. data/spec/integrations/clever_tap_spec.rb +81 -0
  27. data/spec/rubocop_spec.rb +12 -0
  28. data/spec/shared/clever_tap_client.rb +13 -0
  29. data/spec/shared/entity.rb +105 -0
  30. data/spec/spec_helper.rb +18 -0
  31. data/spec/units/clever_tap_client_spec.rb +279 -0
  32. data/spec/units/clever_tap_spec.rb +88 -0
  33. data/spec/units/event_spec.rb +43 -0
  34. data/spec/units/failed_response_spec.rb +31 -0
  35. data/spec/units/profile_spec.rb +29 -0
  36. data/spec/units/response_spec.rb +48 -0
  37. data/spec/units/successful_response_spec.rb +112 -0
  38. data/spec/units/uploader_spec.rb +129 -0
  39. data/spec/vcr_cassettes/CleverTap/uploading_a_many_profiles/when_only_some_are_valid/partially_succeds.yml +42 -0
  40. data/spec/vcr_cassettes/CleverTap/uploading_a_profile/when_is_invalid/fails.yml +41 -0
  41. data/spec/vcr_cassettes/CleverTap/uploading_a_profile/when_is_valid/succeed.yml +35 -0
  42. data/spec/vcr_cassettes/CleverTap/uploading_an_event/when_is_valid/succeed.yml +34 -0
  43. data/spec/vcr_cassettes/CleverTap_Client/_upload/when_upload_records_are_homogenous/and_invalid_records/calls_on_failed_upload_once.yml +38 -0
  44. data/spec/vcr_cassettes/CleverTap_Client/_upload/when_upload_records_are_homogenous/and_invalid_records/returns_an_array_with_one_failed_Response_object.yml +38 -0
  45. data/spec/vcr_cassettes/CleverTap_Client/_upload/when_upload_records_are_homogenous/and_valid_records/and_objects_do_not_fit_upload_limit_/calls_on_successful_upload_proc_twice.yml +67 -0
  46. data/spec/vcr_cassettes/CleverTap_Client/_upload/when_upload_records_are_homogenous/and_valid_records/and_objects_do_not_fit_upload_limit_/returns_an_array_with_two_successful_Response_objects.yml +67 -0
  47. data/spec/vcr_cassettes/CleverTap_Client/_upload/when_upload_records_are_homogenous/and_valid_records/and_objects_fit_upload_limit_/calls_on_successful_upload_proc_once.yml +36 -0
  48. data/spec/vcr_cassettes/CleverTap_Client/_upload/when_upload_records_are_homogenous/and_valid_records/and_objects_fit_upload_limit_/returns_an_array_with_one_successful_Response_object.yml +36 -0
  49. data/spec/vcr_cassettes/CleverTap_Uploader/_call/when_age_is_invalid/behaves_like_validation_failure/failed_to_upload_the_profiles.yml +48 -0
  50. data/spec/vcr_cassettes/CleverTap_Uploader/_call/when_education_status_is_invalid/behaves_like_validation_failure/failed_to_upload_the_profiles.yml +49 -0
  51. data/spec/vcr_cassettes/CleverTap_Uploader/_call/when_email_is_invalid/behaves_like_validation_failure/failed_to_upload_the_profiles.yml +48 -0
  52. data/spec/vcr_cassettes/CleverTap_Uploader/_call/when_employment_status_is_invalid/behaves_like_validation_failure/failed_to_upload_the_profiles.yml +48 -0
  53. data/spec/vcr_cassettes/CleverTap_Uploader/_call/when_marital_status_is_invalid/behaves_like_validation_failure/failed_to_upload_the_profiles.yml +48 -0
  54. data/spec/vcr_cassettes/CleverTap_Uploader/_call/when_phone_is_invalid/behaves_like_validation_failure/failed_to_upload_the_profiles.yml +48 -0
  55. data/spec/vcr_cassettes/CleverTap_Uploader/_call/when_the_creation_date_field_is_missing/behaves_like_validation_failure/failed_to_upload_the_profiles.yml +48 -0
  56. data/spec/vcr_cassettes/CleverTap_Uploader/_call/with_invalid_credentials/failed_to_upload_the_profiles.yml +36 -0
  57. data/spec/vcr_cassettes/CleverTap_Uploader/_call/with_valid_data/makes_successful_upload.yml +36 -0
  58. data/spec/vcr_config.rb +13 -0
  59. metadata +199 -0
@@ -0,0 +1,35 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.clevertap.com/1/upload
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"d":[{"identity":"1","ts":1521649274,"type":"profile","profileData":{"identity":1,"created_at":"2018-03-21
9
+ 18:21:14 +0200","Name":"John Rush","Email":"example@gmail.com","Gender":"M","Phone":"+35922333232","Employed":"Y","Education":"Graduate","Married":"Y","Age":"18"}}]}'
10
+ headers:
11
+ Content-Type:
12
+ - application/json
13
+ X-CleverTap-Account-Id:
14
+ - fake_account_id
15
+ X-CleverTap-Passcode:
16
+ - fake_passcode
17
+ User-Agent:
18
+ - Faraday v0.14.0
19
+ response:
20
+ status:
21
+ code: 200
22
+ message: OK
23
+ headers:
24
+ content-type:
25
+ - application/json;charset=utf-8
26
+ content-length:
27
+ - '63'
28
+ connection:
29
+ - Close
30
+ body:
31
+ encoding: UTF-8
32
+ string: '{ "status" : "success" , "processed" : 1 , "unprocessed" : [ ]}'
33
+ http_version:
34
+ recorded_at: Wed, 21 Mar 2018 16:21:14 GMT
35
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,34 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.clevertap.com/1/upload
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"d":[{"identity":"555","ts":1521649275,"type":"event","evtData":{"ID":555,"mobile":true},"evtName":"register"}]}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ X-CleverTap-Account-Id:
13
+ - fake_account_id
14
+ X-CleverTap-Passcode:
15
+ - fake_passcode
16
+ User-Agent:
17
+ - Faraday v0.14.0
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ content-type:
24
+ - application/json;charset=utf-8
25
+ content-length:
26
+ - '63'
27
+ connection:
28
+ - Close
29
+ body:
30
+ encoding: UTF-8
31
+ string: '{ "status" : "success" , "processed" : 1 , "unprocessed" : [ ]}'
32
+ http_version:
33
+ recorded_at: Wed, 21 Mar 2018 16:21:15 GMT
34
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.clevertap.com/1/upload?dryRun=0
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"d":[{"identity":"1414","type":"profile","profileData":{"ID":"1414","Name":"John","Phone":"+44+441234"}}]}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ X-CleverTap-Account-Id:
13
+ - fake_account_id
14
+ X-CleverTap-Passcode:
15
+ - fake_passcode
16
+ User-Agent:
17
+ - Faraday v0.14.0
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ content-type:
24
+ - application/json;charset=utf-8
25
+ content-length:
26
+ - '323'
27
+ connection:
28
+ - Close
29
+ body:
30
+ encoding: UTF-8
31
+ string: '{ "status" : "fail" , "processed" : 0 , "unprocessed" : [ { "status"
32
+ : "fail" , "code" : 516 , "error" : "Profile data is incorrect. Phone number
33
+ is not valid.Skipped record number : 1" , "record" : { "identity" : "1414"
34
+ , "type" : "profile" , "profileData" : { "ID" : "1414" , "Name" : "John" ,
35
+ "Phone" : "+44+441234"}}}]}'
36
+ http_version:
37
+ recorded_at: Wed, 21 Mar 2018 16:21:18 GMT
38
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.clevertap.com/1/upload?dryRun=0
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"d":[{"identity":"1414","type":"profile","profileData":{"ID":"1414","Name":"John","Phone":"+44+441234"}}]}'
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ X-CleverTap-Account-Id:
13
+ - fake_account_id
14
+ X-CleverTap-Passcode:
15
+ - fake_passcode
16
+ User-Agent:
17
+ - Faraday v0.14.0
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ content-type:
24
+ - application/json;charset=utf-8
25
+ content-length:
26
+ - '323'
27
+ connection:
28
+ - Close
29
+ body:
30
+ encoding: UTF-8
31
+ string: '{ "status" : "fail" , "processed" : 0 , "unprocessed" : [ { "status"
32
+ : "fail" , "code" : 516 , "error" : "Profile data is incorrect. Phone number
33
+ is not valid.Skipped record number : 1" , "record" : { "identity" : "1414"
34
+ , "type" : "profile" , "profileData" : { "ID" : "1414" , "Name" : "John" ,
35
+ "Phone" : "+44+441234"}}}]}'
36
+ http_version:
37
+ recorded_at: Wed, 21 Mar 2018 16:21:18 GMT
38
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,67 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.clevertap.com/1/upload?dryRun=0
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"d":[{"FBID":"1414","type":"event","evtData":{"Name":"John"},"evtName":"Web
9
+ Event"}]}'
10
+ headers:
11
+ Content-Type:
12
+ - application/json
13
+ X-CleverTap-Account-Id:
14
+ - fake_account_id
15
+ X-CleverTap-Passcode:
16
+ - fake_passcode
17
+ User-Agent:
18
+ - Faraday v0.14.0
19
+ response:
20
+ status:
21
+ code: 200
22
+ message: OK
23
+ headers:
24
+ content-type:
25
+ - application/json;charset=utf-8
26
+ content-length:
27
+ - '63'
28
+ connection:
29
+ - Close
30
+ body:
31
+ encoding: UTF-8
32
+ string: '{ "status" : "success" , "processed" : 1 , "unprocessed" : [ ]}'
33
+ http_version:
34
+ recorded_at: Wed, 21 Mar 2018 16:21:17 GMT
35
+ - request:
36
+ method: post
37
+ uri: https://api.clevertap.com/1/upload?dryRun=0
38
+ body:
39
+ encoding: UTF-8
40
+ string: '{"d":[{"FBID":"1515","type":"event","evtData":{"Name":"Jill"},"evtName":"Web
41
+ Event"}]}'
42
+ headers:
43
+ Content-Type:
44
+ - application/json
45
+ X-CleverTap-Account-Id:
46
+ - fake_account_id
47
+ X-CleverTap-Passcode:
48
+ - fake_passcode
49
+ User-Agent:
50
+ - Faraday v0.14.0
51
+ response:
52
+ status:
53
+ code: 200
54
+ message: OK
55
+ headers:
56
+ content-type:
57
+ - application/json;charset=utf-8
58
+ transfer-encoding:
59
+ - chunked
60
+ connection:
61
+ - Close
62
+ body:
63
+ encoding: UTF-8
64
+ string: '{ "status" : "success" , "processed" : 1 , "unprocessed" : [ ]}'
65
+ http_version:
66
+ recorded_at: Wed, 21 Mar 2018 16:21:18 GMT
67
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,67 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.clevertap.com/1/upload?dryRun=0
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"d":[{"FBID":"1414","type":"event","evtData":{"Name":"John"},"evtName":"Web
9
+ Event"}]}'
10
+ headers:
11
+ Content-Type:
12
+ - application/json
13
+ X-CleverTap-Account-Id:
14
+ - fake_account_id
15
+ X-CleverTap-Passcode:
16
+ - fake_passcode
17
+ User-Agent:
18
+ - Faraday v0.14.0
19
+ response:
20
+ status:
21
+ code: 200
22
+ message: OK
23
+ headers:
24
+ content-type:
25
+ - application/json;charset=utf-8
26
+ content-length:
27
+ - '63'
28
+ connection:
29
+ - Close
30
+ body:
31
+ encoding: UTF-8
32
+ string: '{ "status" : "success" , "processed" : 1 , "unprocessed" : [ ]}'
33
+ http_version:
34
+ recorded_at: Wed, 21 Mar 2018 16:21:17 GMT
35
+ - request:
36
+ method: post
37
+ uri: https://api.clevertap.com/1/upload?dryRun=0
38
+ body:
39
+ encoding: UTF-8
40
+ string: '{"d":[{"FBID":"1515","type":"event","evtData":{"Name":"Jill"},"evtName":"Web
41
+ Event"}]}'
42
+ headers:
43
+ Content-Type:
44
+ - application/json
45
+ X-CleverTap-Account-Id:
46
+ - fake_account_id
47
+ X-CleverTap-Passcode:
48
+ - fake_passcode
49
+ User-Agent:
50
+ - Faraday v0.14.0
51
+ response:
52
+ status:
53
+ code: 200
54
+ message: OK
55
+ headers:
56
+ content-type:
57
+ - application/json;charset=utf-8
58
+ content-length:
59
+ - '63'
60
+ connection:
61
+ - Close
62
+ body:
63
+ encoding: UTF-8
64
+ string: '{ "status" : "success" , "processed" : 1 , "unprocessed" : [ ]}'
65
+ http_version:
66
+ recorded_at: Wed, 21 Mar 2018 16:21:17 GMT
67
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.clevertap.com/1/upload?dryRun=0
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"d":[{"FBID":"1414","type":"event","evtData":{"Name":"John"},"evtName":"Web
9
+ Event"},{"FBID":"1515","type":"event","evtData":{"Name":"Jill"},"evtName":"Web
10
+ Event"}]}'
11
+ headers:
12
+ Content-Type:
13
+ - application/json
14
+ X-CleverTap-Account-Id:
15
+ - fake_account_id
16
+ X-CleverTap-Passcode:
17
+ - fake_passcode
18
+ User-Agent:
19
+ - Faraday v0.14.0
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ content-type:
26
+ - application/json;charset=utf-8
27
+ content-length:
28
+ - '63'
29
+ connection:
30
+ - Close
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{ "status" : "success" , "processed" : 2 , "unprocessed" : [ ]}'
34
+ http_version:
35
+ recorded_at: Wed, 21 Mar 2018 16:21:17 GMT
36
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.clevertap.com/1/upload?dryRun=0
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"d":[{"FBID":"1414","type":"event","evtData":{"Name":"John"},"evtName":"Web
9
+ Event"},{"FBID":"1515","type":"event","evtData":{"Name":"Jill"},"evtName":"Web
10
+ Event"}]}'
11
+ headers:
12
+ Content-Type:
13
+ - application/json
14
+ X-CleverTap-Account-Id:
15
+ - fake_account_id
16
+ X-CleverTap-Passcode:
17
+ - fake_passcode
18
+ User-Agent:
19
+ - Faraday v0.14.0
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ content-type:
26
+ - application/json;charset=utf-8
27
+ content-length:
28
+ - '63'
29
+ connection:
30
+ - Close
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{ "status" : "success" , "processed" : 2 , "unprocessed" : [ ]}'
34
+ http_version:
35
+ recorded_at: Wed, 21 Mar 2018 16:21:16 GMT
36
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.clevertap.com/1/upload
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"d":[{"identity":"13","ts":1521649266,"type":"profile","profileData":{"identity":13,"created_at":"2018-03-21
9
+ 18:21:06 +0200","Name":"John Rush","Email":"example@gmail.com","Gender":"M","Phone":"+35922333232","Employed":"Y","Education":"Graduate","Married":"Y","Age":"aa"}},{"identity":"14","ts":1521649266,"type":"profile","profileData":{"identity":14,"created_at":"2018-03-21
10
+ 18:21:06 +0200","Name":"John Rush","Email":"example@gmail.com","Gender":"M","Phone":"+35922333232","Employed":"Y","Education":"Graduate","Married":"Y","Age":"aa"}}]}'
11
+ headers:
12
+ Content-Type:
13
+ - application/json
14
+ X-CleverTap-Account-Id:
15
+ - fake_account_id
16
+ X-CleverTap-Passcode:
17
+ - fake_passcode
18
+ User-Agent:
19
+ - Faraday v0.14.0
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ content-type:
26
+ - application/json;charset=utf-8
27
+ content-length:
28
+ - '965'
29
+ connection:
30
+ - Close
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{ "status" : "fail" , "processed" : 0 , "unprocessed" : [ { "status"
34
+ : "fail" , "code" : 520 , "error" : "Profile data is incorrect. Age is invalid.Skipped
35
+ record number : 1" , "record" : { "identity" : "13" , "ts" : 1521649266 ,
36
+ "type" : "profile" , "profileData" : { "identity" : "13" , "created_at" :
37
+ "2018-03-21 18:21:06 +0200" , "Name" : "John Rush" , "Email" : "example@gmail.com"
38
+ , "Gender" : "M" , "Phone" : 35922333232 , "Employed" : "Y" , "Education"
39
+ : "Graduate" , "Married" : "Y" , "Age" : "aa"}}} , { "status" : "fail" , "code"
40
+ : 520 , "error" : "Profile data is incorrect. Age is invalid.Skipped record
41
+ number : 2" , "record" : { "identity" : "14" , "ts" : 1521649266 , "type"
42
+ : "profile" , "profileData" : { "identity" : "14" , "created_at" : "2018-03-21
43
+ 18:21:06 +0200" , "Name" : "John Rush" , "Email" : "example@gmail.com" , "Gender"
44
+ : "M" , "Phone" : 35922333232 , "Employed" : "Y" , "Education" : "Graduate"
45
+ , "Married" : "Y" , "Age" : "aa"}}}]}'
46
+ http_version:
47
+ recorded_at: Wed, 21 Mar 2018 16:21:07 GMT
48
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,49 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.clevertap.com/1/upload
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"d":[{"identity":"9","ts":1521649266,"type":"profile","profileData":{"identity":9,"created_at":"2018-03-21
9
+ 18:21:06 +0200","Name":"John Rush","Email":"example@gmail.com","Gender":"M","Phone":"+35922333232","Employed":"Y","Education":"223","Married":"Y","Age":"18"}},{"identity":"10","ts":1521649266,"type":"profile","profileData":{"identity":10,"created_at":"2018-03-21
10
+ 18:21:06 +0200","Name":"John Rush","Email":"example@gmail.com","Gender":"M","Phone":"+35922333232","Employed":"Y","Education":"123","Married":"Y","Age":"18"}}]}'
11
+ headers:
12
+ Content-Type:
13
+ - application/json
14
+ X-CleverTap-Account-Id:
15
+ - fake_account_id
16
+ X-CleverTap-Passcode:
17
+ - fake_passcode
18
+ User-Agent:
19
+ - Faraday v0.14.0
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ content-type:
26
+ - application/json;charset=utf-8
27
+ content-length:
28
+ - '1013'
29
+ connection:
30
+ - Close
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{ "status" : "fail" , "processed" : 0 , "unprocessed" : [ { "status"
34
+ : "fail" , "code" : 518 , "error" : "Profile data is incorrect. Education
35
+ needs to be School/College/Graduate..Skipped record number : 1" , "record"
36
+ : { "identity" : "9" , "ts" : 1521649266 , "type" : "profile" , "profileData"
37
+ : { "identity" : 9 , "created_at" : "2018-03-21 18:21:06 +0200" , "Name" :
38
+ "John Rush" , "Email" : "example@gmail.com" , "Gender" : "M" , "Phone" : 35922333232
39
+ , "Employed" : "Y" , "Education" : "223" , "Married" : "Y" , "Age" : "18"}}}
40
+ , { "status" : "fail" , "code" : 518 , "error" : "Profile data is incorrect.
41
+ Education needs to be School/College/Graduate..Skipped record number : 2"
42
+ , "record" : { "identity" : "10" , "ts" : 1521649266 , "type" : "profile"
43
+ , "profileData" : { "identity" : 10 , "created_at" : "2018-03-21 18:21:06
44
+ +0200" , "Name" : "John Rush" , "Email" : "example@gmail.com" , "Gender" :
45
+ "M" , "Phone" : 35922333232 , "Employed" : "Y" , "Education" : "123" , "Married"
46
+ : "Y" , "Age" : "18"}}}]}'
47
+ http_version:
48
+ recorded_at: Wed, 21 Mar 2018 16:21:06 GMT
49
+ recorded_with: VCR 4.0.0