phaxio 0.4.0 → 2.1.0.pre

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 (85) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.travis.yml +11 -0
  4. data/Gemfile +11 -5
  5. data/README.md +296 -40
  6. data/Rakefile +7 -9
  7. data/lib/phaxio.rb +48 -3
  8. data/lib/phaxio/client.rb +151 -241
  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/ata.rb +219 -0
  16. data/lib/phaxio/resources/callback.rb +65 -0
  17. data/lib/phaxio/resources/fax.rb +310 -0
  18. data/lib/phaxio/resources/fax_recipient.rb +41 -0
  19. data/lib/phaxio/resources/phax_code.rb +89 -0
  20. data/lib/phaxio/resources/phone_number.rb +112 -0
  21. data/lib/phaxio/resources/public.rb +8 -0
  22. data/lib/phaxio/resources/public/area_code.rb +64 -0
  23. data/lib/phaxio/resources/public/country.rb +54 -0
  24. data/lib/phaxio/version.rb +1 -1
  25. data/phaxio.gemspec +10 -8
  26. data/spec/client_spec.rb +164 -0
  27. data/spec/helpers/mime_type_helper_spec.rb +11 -0
  28. data/spec/phaxio_spec.rb +20 -0
  29. data/spec/resources/account_spec.rb +24 -0
  30. data/spec/resources/callback_spec.rb +34 -0
  31. data/spec/resources/fax_spec.rb +248 -0
  32. data/spec/resources/phax_code_spec.rb +111 -0
  33. data/spec/resources/phone_number_spec.rb +89 -0
  34. data/spec/resources/public/area_code_spec.rb +24 -0
  35. data/spec/resources/public/country_spec.rb +24 -0
  36. data/spec/spec_helper.rb +6 -0
  37. data/spec/support/credentials.rb +7 -0
  38. data/spec/support/expectations.rb +9 -0
  39. data/spec/support/files/test.pdf +0 -0
  40. data/spec/support/files/test.txt +1 -0
  41. data/spec/support/vcr.rb +8 -0
  42. data/spec/support/vcr_cassettes/resources/account/status.yml +45 -0
  43. data/spec/support/vcr_cassettes/resources/fax/cancel.yml +47 -0
  44. data/spec/support/vcr_cassettes/resources/fax/create.yml +50 -0
  45. data/spec/support/vcr_cassettes/resources/fax/create_for_cancel.yml +50 -0
  46. data/spec/support/vcr_cassettes/resources/fax/create_for_delete.yml +50 -0
  47. data/spec/support/vcr_cassettes/resources/fax/create_for_delete_file.yml +50 -0
  48. data/spec/support/vcr_cassettes/resources/fax/create_for_download_file.yml +50 -0
  49. data/spec/support/vcr_cassettes/resources/fax/create_for_get.yml +50 -0
  50. data/spec/support/vcr_cassettes/resources/fax/create_for_reference.yml +50 -0
  51. data/spec/support/vcr_cassettes/resources/fax/create_for_resend.yml +50 -0
  52. data/spec/support/vcr_cassettes/resources/fax/delete.yml +45 -0
  53. data/spec/support/vcr_cassettes/resources/fax/delete_file.yml +45 -0
  54. data/spec/support/vcr_cassettes/resources/fax/file.yml +50 -0
  55. data/spec/support/vcr_cassettes/resources/fax/get.yml +45 -0
  56. data/spec/support/vcr_cassettes/resources/fax/list.yml +51 -0
  57. data/spec/support/vcr_cassettes/resources/fax/reference.yml +45 -0
  58. data/spec/support/vcr_cassettes/resources/fax/resend.yml +47 -0
  59. data/spec/support/vcr_cassettes/resources/fax/test_receive.yml +51 -0
  60. data/spec/support/vcr_cassettes/resources/phax_code/create.yml +47 -0
  61. data/spec/support/vcr_cassettes/resources/phax_code/create_png.yml +52 -0
  62. data/spec/support/vcr_cassettes/resources/phax_code/get.yml +45 -0
  63. data/spec/support/vcr_cassettes/resources/phax_code/get_id.yml +46 -0
  64. data/spec/support/vcr_cassettes/resources/phax_code/get_id_png.yml +50 -0
  65. data/spec/support/vcr_cassettes/resources/phax_code/get_png.yml +50 -0
  66. data/spec/support/vcr_cassettes/resources/phone_number/create.yml +48 -0
  67. data/spec/support/vcr_cassettes/resources/phone_number/get.yml +46 -0
  68. data/spec/support/vcr_cassettes/resources/phone_number/list.yml +60 -0
  69. data/spec/support/vcr_cassettes/resources/phone_number/release.yml +45 -0
  70. data/spec/support/vcr_cassettes/resources/public/area_codes/list.yml +79 -0
  71. data/spec/support/vcr_cassettes/resources/public/country/list.yml +55 -0
  72. metadata +103 -73
  73. data/test/support/responses/account_status.json +0 -9
  74. data/test/support/responses/cancel_success.json +0 -4
  75. data/test/support/responses/fax_status_success.json +0 -21
  76. data/test/support/responses/list_faxes.json +0 -68
  77. data/test/support/responses/list_numbers.json +0 -22
  78. data/test/support/responses/provision_number.json +0 -12
  79. data/test/support/responses/release_number.json +0 -7
  80. data/test/support/responses/send_failure.json +0 -8
  81. data/test/support/responses/send_success.json +0 -8
  82. data/test/support/responses/test.pdf +0 -0
  83. data/test/support/responses/test_receive.json +0 -4
  84. data/test/test_helper.rb +0 -53
  85. data/test/test_phaxio.rb +0 -72
@@ -1,9 +0,0 @@
1
- {
2
- "success":true,
3
- "message":"Account status retrieved successfully",
4
- "data":{
5
- "faxes_sent_this_month":120,
6
- "faxes_sent_today":10,
7
- "balance":3000
8
- }
9
- }
@@ -1,4 +0,0 @@
1
- {
2
- "success":true,
3
- "message":"Fax canceled successfully."
4
- }
@@ -1,21 +0,0 @@
1
- {
2
- "success":true,
3
- "message":"Retrieved fax successfully",
4
- "data":{
5
- "id":123456,
6
- "num_pages":3,
7
- "cost":21,
8
- "direction":"sent",
9
- "status":"success",
10
- "is_test":true,
11
- "requested_at":1293910680,
12
- "completed_at":1293911100,
13
- "recipients":[
14
- {
15
- "number":"4141234567",
16
- "status":"success",
17
- "completed_at":1293911100
18
- }
19
- ]
20
- }
21
- }
@@ -1,68 +0,0 @@
1
- {
2
- "success":true,
3
- "message":"Retrieved faxes successfully",
4
- "paging":{
5
- "max_per_page":1000,
6
- "page":1,
7
- "total_pages":1,
8
- "total_results":3
9
- },
10
- "data":[
11
- {
12
- "id":123456,
13
- "num_pages":3,
14
- "cost":21,
15
- "direction":"sent",
16
- "status":"success",
17
- "is_test":true,
18
- "requested_at":1293910680,
19
- "completed_at":1293911100,
20
- "recipients":[
21
- {
22
- "number":"4141234567",
23
- "status":"success",
24
- "completed_at":1293911100
25
- }
26
- ]
27
- },
28
- {
29
- "id":123457,
30
- "num_pages":1,
31
- "cost":7,
32
- "direction":"sent",
33
- "status":"success",
34
- "is_test":false,
35
- "requested_at":1293984720,
36
- "completed_at":1293985800,
37
- "recipients":[
38
- {
39
- "number":"4145554567",
40
- "status":"success",
41
- "completed_at":1293985800
42
- }
43
- ]
44
- },
45
- {
46
- "id":123458,
47
- "num_pages":1,
48
- "cost":14,
49
- "direction":"sent",
50
- "status":"success",
51
- "is_test":false,
52
- "requested_at":1294094700,
53
- "completed_at":1294095000,
54
- "recipients":[
55
- {
56
- "number":"4145554568",
57
- "status":"success",
58
- "completed_at":1294095000
59
- },
60
- {
61
- "number":"4145554567",
62
- "status":"success",
63
- "completed_at":1293985800
64
- }
65
- ]
66
- }
67
- ]
68
- }
@@ -1,22 +0,0 @@
1
- {
2
- "success":true,
3
- "message":"Retrieved user phone numbers successfully",
4
- "data":[
5
- {
6
- "number":"8021112222",
7
- "city":"Burlington",
8
- "state":"Vermont",
9
- "cost":200,
10
- "last_billed_at":"2012-10-11 10:51:33",
11
- "provisioned_at":"2012-10-11 10:51:33"
12
- },
13
- {
14
- "number":"8023334444",
15
- "city":"Montpelier",
16
- "state":"Vermont",
17
- "cost":200,
18
- "last_billed_at":"2012-10-11 10:51:33",
19
- "provisioned_at":"2012-10-11 10:51:33"
20
- }
21
- ]
22
- }
@@ -1,12 +0,0 @@
1
- {
2
- "success":true,
3
- "message":"Number provisioned successfully!",
4
- "data":{
5
- "number":"8021112222",
6
- "city":"Burlington",
7
- "state":"Vermont",
8
- "cost":200,
9
- "last_billed_at":"2012-10-11 10:00:44",
10
- "provisioned_at":"2012-10-11 10:00:44"
11
- }
12
- }
@@ -1,7 +0,0 @@
1
- {
2
- "success":true,
3
- "message":"Number released successfully!",
4
- "data":[
5
-
6
- ]
7
- }
@@ -1,8 +0,0 @@
1
- {
2
- "success":false,
3
- "message":"Fax not queued for sending",
4
- "faxId":1234,
5
- "data":{
6
- "faxId":1234
7
- }
8
- }
@@ -1,8 +0,0 @@
1
- {
2
- "success":true,
3
- "message":"Fax queued for sending",
4
- "faxId":1234,
5
- "data":{
6
- "faxId":1234
7
- }
8
- }
Binary file
@@ -1,4 +0,0 @@
1
- {
2
- "success":true,
3
- "message":"Test fax received from 234567890. Calling back now..."
4
- }
data/test/test_helper.rb DELETED
@@ -1,53 +0,0 @@
1
- $:<<(".")
2
- require "test/unit"
3
- require "fakeweb"
4
- require "lib/phaxio"
5
-
6
- Phaxio.config do |config|
7
- config.api_key = "12345678910"
8
- config.api_secret = "10987654321"
9
- end
10
-
11
- FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/send",
12
- :body => File.open("test/support/responses/send_success.json").read,
13
- :content_type => "application/json")
14
-
15
- FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/testReceive",
16
- :body => File.open("test/support/responses/test_receive.json").read,
17
- :content_type => "application/json")
18
-
19
- FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/testReceive",
20
- :body => File.open("test/support/responses/test_receive.json").read,
21
- :content_type => "application/json")
22
-
23
- FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/provisionNumber",
24
- :body => File.open("test/support/responses/provision_number.json").read,
25
- :content_type => "application/json")
26
-
27
- FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/releaseNumber",
28
- :body => File.open("test/support/responses/release_number.json").read,
29
- :content_type => "application/json")
30
-
31
- FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/numberList",
32
- :body => File.open("test/support/responses/list_numbers.json").read,
33
- :content_type => "application/json")
34
-
35
- FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/faxFile",
36
- :body => File.open("test/support/responses/test.pdf").read,
37
- :content_type => "application/pdf")
38
-
39
- FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/faxList",
40
- :body => File.open("test/support/responses/list_faxes.json").read,
41
- :content_type => "application/json")
42
-
43
- FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/faxStatus",
44
- :body => File.open("test/support/responses/fax_status_success.json").read,
45
- :content_type => "application/json")
46
-
47
- FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/faxCancel",
48
- :body => File.open("test/support/responses/cancel_success.json").read,
49
- :content_type => "application/json")
50
-
51
- FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/accountStatus",
52
- :body => File.open("test/support/responses/account_status.json").read,
53
- :content_type => "application/json")
data/test/test_phaxio.rb DELETED
@@ -1,72 +0,0 @@
1
- require_relative "test_helper"
2
-
3
- class TestPhaxio < Test::Unit::TestCase
4
- def test_config
5
- assert_equal "12345678910", Phaxio.api_key
6
- assert_equal "10987654321", Phaxio.api_secret
7
- end
8
-
9
- def test_initialize
10
- end
11
-
12
- def test_send_fax
13
- @response = Phaxio.send_fax(to: "0123456789", filename: "test.pdf")
14
- assert_equal true, @response["success"]
15
- assert_equal "Fax queued for sending", @response["message"]
16
- assert_equal 1234, @response["faxId"]
17
- end
18
-
19
- def test_test_receive
20
- @response = Phaxio.test_receive(filename: "test_file.pdf")
21
- assert_equal true, @response["success"]
22
- assert_equal "Test fax received from 234567890. Calling back now...", @response["message"]
23
- end
24
-
25
- def test_provision_number
26
- @response = Phaxio.provision_number(area_code: 802)
27
- assert_equal true, @response["success"]
28
- assert_equal "Number provisioned successfully!", @response["message"]
29
- assert_equal "Vermont", @response["data"]["state"]
30
- end
31
-
32
- def test_release_number
33
- @response = Phaxio.release_number(number: "8021112222")
34
- assert_equal true, @response["success"]
35
- assert_equal "Number released successfully!", @response["message"]
36
- end
37
-
38
- def test_list_numbers
39
- @response = Phaxio.list_numbers(area_code: 802)
40
- assert_equal true, @response["success"]
41
- assert_equal "Retrieved user phone numbers successfully", @response["message"]
42
- end
43
-
44
- def test_get_fax_file
45
- @response_pdf = Phaxio.get_fax_file(id: 1234, type: p)
46
- assert_equal 6725, @response_pdf.size
47
- end
48
-
49
- def test_list_faxes
50
- @response = Phaxio.list_faxes(start: 1293861600, end: 1294034400)
51
- assert_equal true, @response["success"]
52
- end
53
-
54
- def test_get_fax_status
55
- @response = Phaxio.get_fax_status(id: 123456)
56
- assert_equal true, @response["success"]
57
- assert_equal "Retrieved fax successfully", @response["message"]
58
- end
59
-
60
- def test_cancel_fax
61
- @response = Phaxio.cancel_fax(id: 123456)
62
- assert_equal true, @response["success"]
63
- assert_equal "Fax canceled successfully.", @response["message"]
64
- end
65
-
66
- def test_get_account_status
67
- @response = Phaxio.get_account_status
68
- assert_equal true, @response["success"]
69
- assert_equal "Account status retrieved successfully", @response["message"]
70
- assert_equal 120, @response["data"]["faxes_sent_this_month"]
71
- end
72
- end