phaxio 0.5.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +2 -1
  4. data/Gemfile +10 -0
  5. data/README.md +260 -73
  6. data/Rakefile +6 -16
  7. data/lib/phaxio.rb +47 -3
  8. data/lib/phaxio/client.rb +117 -484
  9. data/lib/phaxio/config.rb +31 -0
  10. data/lib/phaxio/error.rb +13 -0
  11. data/lib/phaxio/helpers/mime_type_helper.rb +14 -0
  12. data/lib/phaxio/resource.rb +168 -0
  13. data/lib/phaxio/resources.rb +7 -0
  14. data/lib/phaxio/resources/account.rb +41 -0
  15. data/lib/phaxio/resources/callback.rb +65 -0
  16. data/lib/phaxio/resources/fax.rb +310 -0
  17. data/lib/phaxio/resources/fax_recipient.rb +41 -0
  18. data/lib/phaxio/resources/phax_code.rb +89 -0
  19. data/lib/phaxio/resources/phone_number.rb +112 -0
  20. data/lib/phaxio/resources/public.rb +8 -0
  21. data/lib/phaxio/resources/public/area_code.rb +64 -0
  22. data/lib/phaxio/resources/public/country.rb +54 -0
  23. data/lib/phaxio/version.rb +1 -1
  24. data/phaxio.gemspec +9 -12
  25. data/spec/client_spec.rb +132 -0
  26. data/spec/helpers/mime_type_helper_spec.rb +11 -0
  27. data/spec/phaxio_spec.rb +20 -0
  28. data/spec/resources/account_spec.rb +24 -0
  29. data/spec/resources/callback_spec.rb +34 -0
  30. data/spec/resources/fax_spec.rb +227 -0
  31. data/spec/resources/phax_code_spec.rb +83 -0
  32. data/spec/resources/phone_number_spec.rb +89 -0
  33. data/spec/resources/public/area_code_spec.rb +24 -0
  34. data/spec/resources/public/country_spec.rb +24 -0
  35. data/spec/spec_helper.rb +6 -0
  36. data/spec/support/credentials.rb +7 -0
  37. data/spec/support/expectations.rb +9 -0
  38. data/spec/support/files/test.pdf +0 -0
  39. data/spec/support/vcr.rb +9 -0
  40. data/spec/support/vcr_cassettes/resources/account/status.yml +44 -0
  41. data/spec/support/vcr_cassettes/resources/fax/cancel.yml +46 -0
  42. data/spec/support/vcr_cassettes/resources/fax/create.yml +230 -0
  43. data/spec/support/vcr_cassettes/resources/fax/delete.yml +44 -0
  44. data/spec/support/vcr_cassettes/resources/fax/delete_file.yml +44 -0
  45. data/spec/support/vcr_cassettes/resources/fax/file.yml +251 -0
  46. data/spec/support/vcr_cassettes/resources/fax/get.yml +44 -0
  47. data/spec/support/vcr_cassettes/resources/fax/list.yml +56 -0
  48. data/spec/support/vcr_cassettes/resources/fax/resend.yml +46 -0
  49. data/spec/support/vcr_cassettes/resources/fax/test_receive.yml +231 -0
  50. data/spec/support/vcr_cassettes/resources/phax_code/create.yml +100 -0
  51. data/spec/support/vcr_cassettes/resources/phax_code/get.yml +190 -0
  52. data/spec/support/vcr_cassettes/resources/phone_number/create.yml +47 -0
  53. data/spec/support/vcr_cassettes/resources/phone_number/get.yml +45 -0
  54. data/spec/support/vcr_cassettes/resources/phone_number/list.yml +52 -0
  55. data/spec/support/vcr_cassettes/resources/phone_number/release.yml +44 -0
  56. data/spec/support/vcr_cassettes/resources/public/area_codes/list.yml +77 -0
  57. data/spec/support/vcr_cassettes/resources/public/country/list.yml +54 -0
  58. metadata +70 -82
  59. data/.ruby-version +0 -1
  60. data/CHANGELOG +0 -6
  61. data/test/files/test.pdf +0 -0
  62. data/test/integration/phaxio_integration_test.rb +0 -45
  63. data/test/support/responses/account_status.json +0 -9
  64. data/test/support/responses/cancel_success.json +0 -4
  65. data/test/support/responses/fax_status_success.json +0 -21
  66. data/test/support/responses/list_faxes.json +0 -68
  67. data/test/support/responses/list_numbers.json +0 -22
  68. data/test/support/responses/provision_number.json +0 -12
  69. data/test/support/responses/release_number.json +0 -7
  70. data/test/support/responses/send_failure.json +0 -8
  71. data/test/support/responses/send_success.json +0 -8
  72. data/test/support/responses/test.pdf +0 -0
  73. data/test/support/responses/test_receive.json +0 -4
  74. data/test/test_helper.rb +0 -57
  75. data/test/test_phaxio.rb +0 -128
@@ -0,0 +1,100 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.phaxio.com/v2/phax_codes
6
+ body:
7
+ encoding: UTF-8
8
+ string: api_key=<API_KEY>&api_secret=<API_SECRET>&metadata=This+is+a+test+PhaxCode
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.13.1
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ response:
15
+ status:
16
+ code: 200
17
+ message:
18
+ headers:
19
+ cache-control:
20
+ - max-age=0, private, must-revalidate
21
+ content-type:
22
+ - application/json; charset=utf-8
23
+ date:
24
+ - Mon, 06 Nov 2017 15:04:39 GMT
25
+ etag:
26
+ - W/"2cecb91a8d9f69a75263567882a37e0d"
27
+ server:
28
+ - nginx
29
+ strict-transport-security:
30
+ - max-age=15768000; preload
31
+ x-request-id:
32
+ - 6c8432f1-7d3a-4d5a-9fa0-e3c9d62428ea
33
+ x-robots-tag:
34
+ - noindex, nofollow, nosnippet, noarchive
35
+ x-runtime:
36
+ - '0.047297'
37
+ content-length:
38
+ - '78'
39
+ connection:
40
+ - Close
41
+ body:
42
+ encoding: UTF-8
43
+ string: '{"success":true,"message":"PhaxCode generated","data":{"identifier":"-Y3jxX"}}'
44
+ http_version:
45
+ recorded_at: Mon, 06 Nov 2017 15:04:39 GMT
46
+ - request:
47
+ method: post
48
+ uri: https://api.phaxio.com/v2/phax_codes.png
49
+ body:
50
+ encoding: UTF-8
51
+ string: api_key=<API_KEY>&api_secret=<API_SECRET>&metadata=This+is+a+test+PhaxCode&type=png
52
+ headers:
53
+ User-Agent:
54
+ - Faraday v0.13.1
55
+ Content-Type:
56
+ - application/x-www-form-urlencoded
57
+ response:
58
+ status:
59
+ code: 200
60
+ message:
61
+ headers:
62
+ cache-control:
63
+ - private
64
+ content-disposition:
65
+ - attachment
66
+ content-transfer-encoding:
67
+ - binary
68
+ content-type:
69
+ - image/png
70
+ date:
71
+ - Mon, 06 Nov 2017 15:04:41 GMT
72
+ etag:
73
+ - W/"dd5e58fe454c84aeba9f112d93810c72"
74
+ server:
75
+ - nginx
76
+ strict-transport-security:
77
+ - max-age=15768000; preload
78
+ x-request-id:
79
+ - eb51628e-1cc9-4dd4-90f0-d89b1e98aa63
80
+ x-robots-tag:
81
+ - noindex, nofollow, nosnippet, noarchive
82
+ x-runtime:
83
+ - '0.025869'
84
+ content-length:
85
+ - '288'
86
+ connection:
87
+ - Close
88
+ body:
89
+ encoding: ASCII-8BIT
90
+ string: !binary |-
91
+ iVBORw0KGgoAAAANSUhEUgAAARgAAAA+CAIAAAB/bpNEAAAA50lEQVR42u3Y
92
+ QQqDMBBAUUe8/5WnC0EKQ8LQZGHhvVUJJjbaj8XIzANYc7oEICQQEggJEBLs
93
+ dNWhiHg+3+/07pHv93t1pK4wn1v9dsxopK7QmdvZdT2mv4s6a3Su0RnXd7q+
94
+ /t57MT9+NNL/vc132rlTne/giQT+2oGQQEiAkEBIICQQEiAkEBIICYQECAmE
95
+ BEICIQFCAiGBkEBIgJBASCAkEBIgJBASCAkQEggJhARCAoQEQgIhgZAAIYGQ
96
+ QEggJEBIICQQEggJEBIICYQEQgKEBEKCPxaZ6SqAJxIICYQECAmEBG/yAWi2
97
+ dXdhYc11AAAAAElFTkSuQmCC
98
+ http_version:
99
+ recorded_at: Mon, 06 Nov 2017 15:04:41 GMT
100
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,190 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.phaxio.com/v2/phax_code?api_key=<API_KEY>&api_secret=<API_SECRET>
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.13.1
12
+ response:
13
+ status:
14
+ code: 200
15
+ message:
16
+ headers:
17
+ cache-control:
18
+ - max-age=0, private, must-revalidate
19
+ content-type:
20
+ - application/json; charset=utf-8
21
+ date:
22
+ - Mon, 06 Nov 2017 15:21:51 GMT
23
+ etag:
24
+ - W/"96cc5eb352a319563126200fc9b76b07"
25
+ server:
26
+ - nginx
27
+ strict-transport-security:
28
+ - max-age=15768000; preload
29
+ x-request-id:
30
+ - 45b51898-2ec6-4b3b-9b2e-e3a02b32241b
31
+ x-robots-tag:
32
+ - noindex, nofollow, nosnippet, noarchive
33
+ x-runtime:
34
+ - '0.014458'
35
+ content-length:
36
+ - '122'
37
+ connection:
38
+ - Close
39
+ body:
40
+ encoding: UTF-8
41
+ string: '{"success":true,"message":"Info for PhaxCode","data":{"identifier":"1eKfEx","created_at":"2017-11-06T09:19:44.000-06:00"}}'
42
+ http_version:
43
+ recorded_at: Mon, 06 Nov 2017 15:21:51 GMT
44
+ - request:
45
+ method: get
46
+ uri: https://api.phaxio.com/v2/phax_code.png?api_key=<API_KEY>&api_secret=<API_SECRET>
47
+ body:
48
+ encoding: US-ASCII
49
+ string: ''
50
+ headers:
51
+ User-Agent:
52
+ - Faraday v0.13.1
53
+ response:
54
+ status:
55
+ code: 200
56
+ message:
57
+ headers:
58
+ cache-control:
59
+ - private
60
+ content-disposition:
61
+ - attachment
62
+ content-transfer-encoding:
63
+ - binary
64
+ content-type:
65
+ - image/png
66
+ date:
67
+ - Mon, 06 Nov 2017 15:21:52 GMT
68
+ etag:
69
+ - W/"df5f92a4c6622343cee2edf6cd8e0efc"
70
+ server:
71
+ - nginx
72
+ strict-transport-security:
73
+ - max-age=15768000; preload
74
+ x-request-id:
75
+ - 1d9fdb69-d179-4c74-945e-a82f9a15f510
76
+ x-robots-tag:
77
+ - noindex, nofollow, nosnippet, noarchive
78
+ x-runtime:
79
+ - '0.029481'
80
+ content-length:
81
+ - '286'
82
+ connection:
83
+ - Close
84
+ body:
85
+ encoding: ASCII-8BIT
86
+ string: !binary |-
87
+ iVBORw0KGgoAAAANSUhEUgAAARgAAAA+CAIAAAB/bpNEAAAA5UlEQVR42u3Y
88
+ QQqDMBBAUUe8/5XHhVCEwTBaBYX3ViVtQkz7sRiZOQH/mR0BCAmEBEIChAR3
89
+ WupQRPxeb8/0tpH98706UlcYz62ufeZopK7Qmdu56s6e6wr13WsnWVcY762/
90
+ QudUz/5Onvg2+7PGu7339NyRwF87EBIICRASCAmEBEIChARCAiGBkAAhgZBA
91
+ SCAkQEggJBASCAkQEggJhARCAoQEQgIhAUICIYGQQEiAkEBIICQQEiAkEBII
92
+ CYQECAmEBEICIQFCAiGBkEBIgJBASPBhkZlOAdyRQEggJEBIICR4kxVkfXV3
93
+ BcB7rQAAAABJRU5ErkJggg==
94
+ http_version:
95
+ recorded_at: Mon, 06 Nov 2017 15:21:52 GMT
96
+ - request:
97
+ method: get
98
+ uri: https://api.phaxio.com/v2/phax_codes/-Y3jxX?api_key=<API_KEY>&api_secret=<API_SECRET>
99
+ body:
100
+ encoding: US-ASCII
101
+ string: ''
102
+ headers:
103
+ User-Agent:
104
+ - Faraday v0.13.1
105
+ response:
106
+ status:
107
+ code: 200
108
+ message:
109
+ headers:
110
+ cache-control:
111
+ - max-age=0, private, must-revalidate
112
+ content-type:
113
+ - application/json; charset=utf-8
114
+ date:
115
+ - Mon, 06 Nov 2017 15:21:54 GMT
116
+ etag:
117
+ - W/"1e8a0028114a1f0265e8c4268fbe6285"
118
+ server:
119
+ - nginx
120
+ strict-transport-security:
121
+ - max-age=15768000; preload
122
+ x-request-id:
123
+ - f7395875-d93f-4c36-8459-95ffd173ac09
124
+ x-robots-tag:
125
+ - noindex, nofollow, nosnippet, noarchive
126
+ x-runtime:
127
+ - '0.023037'
128
+ content-length:
129
+ - '159'
130
+ connection:
131
+ - Close
132
+ body:
133
+ encoding: UTF-8
134
+ string: '{"success":true,"message":"Info for PhaxCode","data":{"identifier":"-Y3jxX","created_at":"2017-11-06T08:57:46.000-06:00","metadata":"This
135
+ is a test PhaxCode"}}'
136
+ http_version:
137
+ recorded_at: Mon, 06 Nov 2017 15:21:54 GMT
138
+ - request:
139
+ method: get
140
+ uri: https://api.phaxio.com/v2/phax_codes/-Y3jxX.png?api_key=<API_KEY>&api_secret=<API_SECRET>
141
+ body:
142
+ encoding: US-ASCII
143
+ string: ''
144
+ headers:
145
+ User-Agent:
146
+ - Faraday v0.13.1
147
+ response:
148
+ status:
149
+ code: 200
150
+ message:
151
+ headers:
152
+ cache-control:
153
+ - private
154
+ content-disposition:
155
+ - attachment
156
+ content-transfer-encoding:
157
+ - binary
158
+ content-type:
159
+ - image/png
160
+ date:
161
+ - Mon, 06 Nov 2017 15:21:55 GMT
162
+ etag:
163
+ - W/"dd5e58fe454c84aeba9f112d93810c72"
164
+ server:
165
+ - nginx
166
+ strict-transport-security:
167
+ - max-age=15768000; preload
168
+ x-request-id:
169
+ - 4127a8e7-383d-4034-8290-ad61d8805729
170
+ x-robots-tag:
171
+ - noindex, nofollow, nosnippet, noarchive
172
+ x-runtime:
173
+ - '0.026291'
174
+ content-length:
175
+ - '288'
176
+ connection:
177
+ - Close
178
+ body:
179
+ encoding: ASCII-8BIT
180
+ string: !binary |-
181
+ iVBORw0KGgoAAAANSUhEUgAAARgAAAA+CAIAAAB/bpNEAAAA50lEQVR42u3Y
182
+ QQqDMBBAUUe8/5WnC0EKQ8LQZGHhvVUJJjbaj8XIzANYc7oEICQQEggJEBLs
183
+ dNWhiHg+3+/07pHv93t1pK4wn1v9dsxopK7QmdvZdT2mv4s6a3Su0RnXd7q+
184
+ /t57MT9+NNL/vc132rlTne/giQT+2oGQQEiAkEBIICQQEiAkEBIICYQECAmE
185
+ BEICIQFCAiGBkEBIgJBASCAkEBIgJBASCAkQEggJhARCAoQEQgIhgZAAIYGQ
186
+ QEggJEBIICQQEggJEBIICYQEQgKEBEKCPxaZ6SqAJxIICYQECAmEBG/yAWi2
187
+ dXdhYc11AAAAAElFTkSuQmCC
188
+ http_version:
189
+ recorded_at: Mon, 06 Nov 2017 15:21:55 GMT
190
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.phaxio.com/v2/phone_numbers
6
+ body:
7
+ encoding: UTF-8
8
+ string: api_key=<API_KEY>&api_secret=<API_SECRET>&area_code=225&country_code=1
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.13.1
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ response:
15
+ status:
16
+ code: 200
17
+ message:
18
+ headers:
19
+ cache-control:
20
+ - max-age=0, private, must-revalidate
21
+ content-type:
22
+ - application/json; charset=utf-8
23
+ date:
24
+ - Tue, 31 Oct 2017 02:51:12 GMT
25
+ etag:
26
+ - W/"8a85980fdbb5f8f3cb813a1704f55ac8"
27
+ server:
28
+ - nginx
29
+ strict-transport-security:
30
+ - max-age=15768000; preload
31
+ x-request-id:
32
+ - ef857553-09d4-4144-95f3-e2681de3f72a
33
+ x-robots-tag:
34
+ - noindex, nofollow, nosnippet, noarchive
35
+ x-runtime:
36
+ - '0.189105'
37
+ content-length:
38
+ - '307'
39
+ connection:
40
+ - Close
41
+ body:
42
+ encoding: UTF-8
43
+ string: '{"success":true,"message":"Number provisioned successfully!","data":{"phone_number":"+12255000373","city":"Baton
44
+ Rouge","state":"Louisiana","country":"United States of America","cost":200,"last_billed_at":"2017-10-30T21:51:12.000-05:00","provisioned_at":"2017-10-30T21:51:12.000-05:00","callback_url":null}}'
45
+ http_version:
46
+ recorded_at: Tue, 31 Oct 2017 02:51:13 GMT
47
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.phaxio.com/v2/phone_numbers/12258675309?api_key=<API_KEY>&api_secret=<API_SECRET>
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.13.1
12
+ response:
13
+ status:
14
+ code: 200
15
+ message:
16
+ headers:
17
+ cache-control:
18
+ - max-age=0, private, must-revalidate
19
+ content-type:
20
+ - application/json; charset=utf-8
21
+ date:
22
+ - Tue, 31 Oct 2017 02:55:10 GMT
23
+ etag:
24
+ - W/"b1274ae296f2576fae570b91c9baa18d"
25
+ server:
26
+ - nginx
27
+ strict-transport-security:
28
+ - max-age=15768000; preload
29
+ x-request-id:
30
+ - 0499ad65-5f3c-4830-aa10-12c88973d2ee
31
+ x-robots-tag:
32
+ - noindex, nofollow, nosnippet, noarchive
33
+ x-runtime:
34
+ - '0.041250'
35
+ content-length:
36
+ - '316'
37
+ connection:
38
+ - Close
39
+ body:
40
+ encoding: UTF-8
41
+ string: '{"success":true,"message":"Retrieved user phone numbers successfully","data":{"phone_number":"+12258675309","city":"Baton
42
+ Rouge","state":"Louisiana","country":"United States of America","cost":200,"last_billed_at":"2017-10-30T21:51:12.000-05:00","provisioned_at":"2017-10-30T21:51:12.000-05:00","callback_url":null}}'
43
+ http_version:
44
+ recorded_at: Tue, 31 Oct 2017 02:55:10 GMT
45
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.phaxio.com/v2/phone_numbers?api_key=<API_KEY>&api_secret=<API_SECRET>
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.13.1
12
+ response:
13
+ status:
14
+ code: 200
15
+ message:
16
+ headers:
17
+ cache-control:
18
+ - max-age=0, private, must-revalidate
19
+ content-type:
20
+ - application/json; charset=utf-8
21
+ date:
22
+ - Tue, 31 Oct 2017 02:57:00 GMT
23
+ etag:
24
+ - W/"d146491212cda96fc08f7e8a8e6e5147"
25
+ server:
26
+ - nginx
27
+ strict-transport-security:
28
+ - max-age=15768000; preload
29
+ x-page:
30
+ - '1'
31
+ x-per-page:
32
+ - '25'
33
+ x-request-id:
34
+ - 711de3a2-8f35-4983-b349-c57dba2a550d
35
+ x-robots-tag:
36
+ - noindex, nofollow, nosnippet, noarchive
37
+ x-runtime:
38
+ - '0.060597'
39
+ x-total:
40
+ - '2'
41
+ content-length:
42
+ - '601'
43
+ connection:
44
+ - Close
45
+ body:
46
+ encoding: UTF-8
47
+ string: '{"success":true,"message":"Retrieved user phone numbers successfully","data":[{"phone_number":"+15558675309","city":"Baton
48
+ Rouge","state":"Louisiana","country":"United States of America","cost":200,"last_billed_at":"2017-10-13T15:32:37.000-05:00","provisioned_at":"2016-10-13T15:32:37.000-05:00","callback_url":null},{"phone_number":"+12255000373","city":"Baton
49
+ Rouge","state":"Louisiana","country":"United States of America","cost":200,"last_billed_at":"2017-10-30T21:51:12.000-05:00","provisioned_at":"2017-10-30T21:51:12.000-05:00","callback_url":null}],"paging":{"total":2,"per_page":25,"page":1}}'
50
+ http_version:
51
+ recorded_at: Tue, 31 Oct 2017 02:57:01 GMT
52
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: https://api.phaxio.com/v2/phone_numbers/+12258675309?api_key=<API_KEY>&api_secret=<API_SECRET>
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.13.1
12
+ response:
13
+ status:
14
+ code: 200
15
+ message:
16
+ headers:
17
+ cache-control:
18
+ - max-age=0, private, must-revalidate
19
+ content-type:
20
+ - application/json; charset=utf-8
21
+ date:
22
+ - Tue, 31 Oct 2017 03:01:31 GMT
23
+ etag:
24
+ - W/"72f232a3122ac0559f594e0dc20e2512"
25
+ server:
26
+ - nginx
27
+ strict-transport-security:
28
+ - max-age=15768000; preload
29
+ x-request-id:
30
+ - 5d9baff3-8717-45d1-a3e8-519163964b82
31
+ x-robots-tag:
32
+ - noindex, nofollow, nosnippet, noarchive
33
+ x-runtime:
34
+ - '0.093251'
35
+ content-length:
36
+ - '58'
37
+ connection:
38
+ - Close
39
+ body:
40
+ encoding: UTF-8
41
+ string: '{"success":true,"message":"Number released successfully!"}'
42
+ http_version:
43
+ recorded_at: Tue, 31 Oct 2017 03:01:31 GMT
44
+ recorded_with: VCR 3.0.3