phaxio 0.1.0 → 0.4.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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +10 -0
- data/Gemfile +0 -5
- data/README.md +39 -12
- data/lib/phaxio/client.rb +148 -34
- data/lib/phaxio/version.rb +1 -1
- data/lib/phaxio.rb +1 -1
- data/phaxio.gemspec +8 -5
- data/test/support/responses/list_faxes.json +68 -0
- data/test/support/responses/list_numbers.json +22 -0
- data/test/support/responses/provision_number.json +12 -0
- data/test/support/responses/release_number.json +7 -0
- data/test/support/responses/test.pdf +0 -0
- data/test/test_helper.rb +27 -1
- data/test/test_phaxio.rb +37 -16
- metadata +61 -42
- data/test/support/account_status.json +0 -9
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 7dfb55296264298ff1a5e2cb1d0023139f40e38a
|
|
4
|
+
data.tar.gz: 3d8f431ec99140798feb5b2d44a48f0ace04a59a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 1ec3d6e31a9410f4dbac626a13ae2543b76a219fd79906a8e5b2cf926e47b5175aa94507842584a0b07b1c37d139a19696114c35d85f49ee77a712c289205d49
|
|
7
|
+
data.tar.gz: 48aa273d74b05dc1a047c55cf714c76d07e32fe0102ee3f634b5bf94c2250f06742cb0b9a289f1e6abd16c6cf0df3b0124a7f5f6e27297834e4af3c6fd6692a7
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.2
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# Phaxio
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://travis-ci.org/gristmill/phaxio)
|
|
4
4
|
|
|
5
|
+
A Ruby gem for interacting with the [Phaxio API]( https://www.phaxio.com/docs ).
|
|
5
6
|
|
|
7
|
+
**Note: This gem only runs on Ruby version 1.9.+**
|
|
6
8
|
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
@@ -20,24 +22,49 @@ Or install it yourself as:
|
|
|
20
22
|
|
|
21
23
|
## Usage
|
|
22
24
|
|
|
23
|
-
Configure
|
|
25
|
+
Configure Phaxio with your api_key and api_secret:
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
config.api_key = 10987654321
|
|
27
|
-
config.api_secret = 12345678910
|
|
27
|
+
Phaxio.config do |config|
|
|
28
|
+
config.api_key = "10987654321"
|
|
29
|
+
config.api_secret = "12345678910"
|
|
28
30
|
end
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
To send a fax:
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
Phaxio.send_fax(to: "0123456789", filename: File.new("test.pdf"))
|
|
33
35
|
|
|
34
36
|
### Currently Supported API Calls
|
|
35
37
|
|
|
36
|
-
* send_fax
|
|
37
|
-
* test_receive
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* send_fax - `Phaxio.send_fax(to: "0123456789", filename: File.new("test.pdf"))`
|
|
39
|
+
* test_receive - `Phaxio.test_receive(filename: "test_file.pdf")`
|
|
40
|
+
* provision_number - `Phaxio.provision_number(area_code: 802)`
|
|
41
|
+
* release_number - `Phaxio.release_number(number: "8021112222")`
|
|
42
|
+
* list_numbers - `Phaxio.list_numbers(area_code: 802)`
|
|
43
|
+
* get_fax_file - `Phaxio.get_fax_file(id: 123456, type: p)`
|
|
44
|
+
* list_faxes - `Phaxio.list_numbers(area_code: 802)`
|
|
45
|
+
* list_faxes - `Phaxio.list_faxes(start: Time.now - 48000,
|
|
46
|
+
end: Time.now)`
|
|
47
|
+
* get_fax_status - `Phaxio.get_fax_status(id: 123456)`
|
|
48
|
+
* cancel_fax - `Phaxio.cancel_fax(id: 123456)`
|
|
49
|
+
* get_account_status - `Phaxio.get_account_status`
|
|
50
|
+
|
|
51
|
+
### Example
|
|
52
|
+
|
|
53
|
+
require 'phaxio'
|
|
54
|
+
|
|
55
|
+
Phaxio.config do |config|
|
|
56
|
+
config.api_key = "your_key"
|
|
57
|
+
config.api_secret = "your_secret"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
@fax = Phaxio.send_fax(to: '15555555555', string_data: "hello world")
|
|
61
|
+
Phaxio.get_fax_status(id: @fax["faxId"])
|
|
62
|
+
|
|
63
|
+
# Get a Fax and save it as a PDF
|
|
64
|
+
@pdf = Phaxio.get_fax_file(id: @fax["faxId"], type: "p")
|
|
65
|
+
File.open("received_test.pdf", "w") do |file|
|
|
66
|
+
file << @pdf
|
|
67
|
+
end
|
|
41
68
|
|
|
42
69
|
## Contributing
|
|
43
70
|
|
data/lib/phaxio/client.rb
CHANGED
|
@@ -1,30 +1,12 @@
|
|
|
1
1
|
module Phaxio
|
|
2
|
+
include HTTMultiParty
|
|
3
|
+
base_uri 'https://api.phaxio.com/v1'
|
|
4
|
+
|
|
2
5
|
module Config
|
|
3
6
|
attr_accessor :api_key, :api_secret
|
|
4
7
|
end
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
include HTTParty
|
|
8
|
-
base_uri 'https://api.phaxio.com/v1'
|
|
9
|
-
|
|
10
|
-
# Public: Initialize a new Client.
|
|
11
|
-
#
|
|
12
|
-
# Returns nothing.
|
|
13
|
-
def initialize
|
|
14
|
-
extend(Config)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# Public: Configure a Client.
|
|
18
|
-
#
|
|
19
|
-
# Returns the Client.
|
|
20
|
-
def config
|
|
21
|
-
if block_given?
|
|
22
|
-
yield(self)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
self
|
|
26
|
-
end
|
|
27
|
-
|
|
9
|
+
module Client
|
|
28
10
|
# Public: Send a fax.
|
|
29
11
|
#
|
|
30
12
|
# options - The Hash options used to refine the selection (default: {}):
|
|
@@ -76,11 +58,14 @@ module Phaxio
|
|
|
76
58
|
# completed. Must be between 1 and 60
|
|
77
59
|
# (optional).
|
|
78
60
|
#
|
|
61
|
+
# Examples
|
|
62
|
+
#
|
|
63
|
+
# Phaxio.send_fax(to: "0123456789", filename: "test.pdf")
|
|
64
|
+
#
|
|
79
65
|
# Returns a HTTParty::Response object containing a success bool,
|
|
80
66
|
# a String message, and an in faxID.
|
|
81
67
|
def send_fax(options)
|
|
82
|
-
|
|
83
|
-
self.class.post("/send", options)
|
|
68
|
+
send_post("/send", options)
|
|
84
69
|
end
|
|
85
70
|
|
|
86
71
|
# Public: Test receiving a fax.
|
|
@@ -93,11 +78,114 @@ module Phaxio
|
|
|
93
78
|
# a PhaxCode and is the file you want to simulate
|
|
94
79
|
# sending (required).
|
|
95
80
|
#
|
|
81
|
+
# Examples
|
|
82
|
+
#
|
|
83
|
+
# Phaxio.test_receive(filename: "test_file.pdf")
|
|
84
|
+
#
|
|
96
85
|
# Returns a HTTParty::Response object containing a success bool
|
|
97
86
|
# and a String message.
|
|
98
87
|
def test_receive(options)
|
|
99
|
-
|
|
100
|
-
|
|
88
|
+
send_post("/testReceive", options)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Public: Provision a phone number that you can use to receive faxes in
|
|
92
|
+
# your Phaxio account.
|
|
93
|
+
#
|
|
94
|
+
# options - The Hash options used to refine the selection (default: {}):
|
|
95
|
+
# area_code - The integer area code of the number you'd like
|
|
96
|
+
# to provision (required).
|
|
97
|
+
# callback_url - A callback URL that Phaxio will post to when a
|
|
98
|
+
# fax is received by this number. This will
|
|
99
|
+
# override the global receive callback URL, if you
|
|
100
|
+
# have one set (optional).
|
|
101
|
+
#
|
|
102
|
+
# Examples
|
|
103
|
+
#
|
|
104
|
+
# Phaxio.provision_number(area_code: 802)
|
|
105
|
+
#
|
|
106
|
+
# Returns a HTTParty::Response object containing a success bool, a string
|
|
107
|
+
# message, and data containing the phone number, city, state, cost,
|
|
108
|
+
# last_billed_at, and the date the number was provisioned at.
|
|
109
|
+
def provision_number(options)
|
|
110
|
+
send_post("/provisionNumber", options)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Public: Release a phone number that you no longer need. Once a phone
|
|
114
|
+
# number is released you will no longer be charged for it.
|
|
115
|
+
#
|
|
116
|
+
# options - The Hash options used to refine the selection (default: {}):
|
|
117
|
+
# number - The String of the phone number you want to release
|
|
118
|
+
# (required).
|
|
119
|
+
#
|
|
120
|
+
# Examples
|
|
121
|
+
#
|
|
122
|
+
# Phaxio.release_number(number: "8021112222")
|
|
123
|
+
#
|
|
124
|
+
# Returns a HTTParty::Response object containing a success bool and a
|
|
125
|
+
# string message.
|
|
126
|
+
def release_number(options)
|
|
127
|
+
send_post("/releaseNumber", options)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Public: Get a detailed list of the phone numbers you current own on
|
|
131
|
+
# Phaxio.
|
|
132
|
+
#
|
|
133
|
+
# options - The Hash options used to refne th selection (default: {}):
|
|
134
|
+
# area_code - An integer area code you'd like to filter by
|
|
135
|
+
# (optional).
|
|
136
|
+
# number - A String phone number you'd like to retrieve
|
|
137
|
+
# (optional).
|
|
138
|
+
#
|
|
139
|
+
# Examples
|
|
140
|
+
#
|
|
141
|
+
# Phaxio.list_numbers # list all the numbers you own
|
|
142
|
+
#
|
|
143
|
+
# Phaxio.list_numbers(area_code: 802) # list all numbers in the 802 area
|
|
144
|
+
#
|
|
145
|
+
# Phaxio.list_numbers(number: "8021112222") # show specific number detail
|
|
146
|
+
#
|
|
147
|
+
# Returns a HTTParty::Reponse object containing a success bool, a message,
|
|
148
|
+
# and the data attributes containing the queried phone number(s) details.
|
|
149
|
+
def list_numbers(options = {})
|
|
150
|
+
send_post("/numberList", options)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Public: Get an image thumbnail or PDF file for a fax. For images to work
|
|
154
|
+
# file storage must not be disabled with Phaxio.
|
|
155
|
+
#
|
|
156
|
+
# options - The Hash options used to refine the selection (default: {}):
|
|
157
|
+
# id - The integer fax id of the fax you wish to retreive
|
|
158
|
+
# (required).
|
|
159
|
+
# type - An enum for the type return, defaults to 'p' (optional):
|
|
160
|
+
# s - Small JPG format thumbnail of the fax, 129 x 167 px.
|
|
161
|
+
# l - Large JPG format thumbnail of the fax, 300 x 388 px.
|
|
162
|
+
# p - PDF version of the fax (default).
|
|
163
|
+
#
|
|
164
|
+
# Examples
|
|
165
|
+
#
|
|
166
|
+
# Phaxio.get_fax_file(id: 1234, type: p)
|
|
167
|
+
# Phaxio.get_fax_file(id: 3254, type: l)
|
|
168
|
+
#
|
|
169
|
+
# Returns the fax as the type specified in the call, defaults to PDF.
|
|
170
|
+
def get_fax_file(options)
|
|
171
|
+
send_post("/faxFile", options)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Public: List faxes within the specified time range.
|
|
175
|
+
#
|
|
176
|
+
# options - The Hash options used to refine the selection (default: {}):
|
|
177
|
+
# start - The Unix Timestamp for the beginning of the range
|
|
178
|
+
# (required).
|
|
179
|
+
# end - The Unix Timestamp for the end of the range (required).
|
|
180
|
+
#
|
|
181
|
+
# Examples
|
|
182
|
+
#
|
|
183
|
+
# Phaxio.list_faxes(start: 1293861600, end: 1294034400)
|
|
184
|
+
#
|
|
185
|
+
# Returns a HTTParty::Response object containing a success bool, a string
|
|
186
|
+
# message, paging information, and the fax data.
|
|
187
|
+
def list_faxes(options)
|
|
188
|
+
send_post("/faxList", options)
|
|
101
189
|
end
|
|
102
190
|
|
|
103
191
|
# Public: Get the status of a specific fax.
|
|
@@ -106,15 +194,18 @@ module Phaxio
|
|
|
106
194
|
# id - The int id of the fax you want to get the status of
|
|
107
195
|
# (required).
|
|
108
196
|
#
|
|
197
|
+
# Examples
|
|
198
|
+
#
|
|
199
|
+
# Phaxio.get_fax_status(id: "123456")
|
|
200
|
+
#
|
|
109
201
|
# Returns a HTTParty::Response object containing a success bool,
|
|
110
202
|
# a String message, and the data of the fax.
|
|
111
203
|
def get_fax_status(options)
|
|
112
204
|
if options[:id].nil?
|
|
113
205
|
raise StandardError, "You must include a fax id."
|
|
114
206
|
end
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
self.class.post("/faxStatus", options)
|
|
207
|
+
|
|
208
|
+
send_post("/faxStatus", options)
|
|
118
209
|
end
|
|
119
210
|
|
|
120
211
|
# Public: Cancel a specific fax.
|
|
@@ -122,24 +213,47 @@ module Phaxio
|
|
|
122
213
|
# options - The Hash options used to refine the selection (defaults: {}):
|
|
123
214
|
# id - The int id of the fax you want to cancel (required).
|
|
124
215
|
#
|
|
216
|
+
# Examples
|
|
217
|
+
#
|
|
218
|
+
# Phaxio.cancel_fax(id: "123456")
|
|
219
|
+
#
|
|
125
220
|
# Returns a HTTParty::Response object containing a success bool
|
|
126
221
|
# and a String message.
|
|
127
222
|
def cancel_fax(options)
|
|
128
|
-
|
|
129
|
-
self.class.post("/faxCancel", options)
|
|
223
|
+
send_post("/faxCancel", options)
|
|
130
224
|
end
|
|
131
225
|
|
|
132
226
|
# Public: Get the status of Client's account.
|
|
133
227
|
#
|
|
228
|
+
# Examples
|
|
229
|
+
#
|
|
230
|
+
# Phaxio.get_account_status
|
|
231
|
+
#
|
|
134
232
|
# Returns a HTTParty::Response object with success, message, and data
|
|
135
233
|
# (containing faxes_sent_this_month, faxes_sent_today, and balance).
|
|
136
234
|
def get_account_status
|
|
137
|
-
|
|
235
|
+
send_post("/accountStatus", {})
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def send_post(path, options)
|
|
239
|
+
post(path, query: options.merge!({api_key: api_key, api_secret: api_secret}))
|
|
138
240
|
end
|
|
139
241
|
end
|
|
140
242
|
|
|
141
|
-
|
|
142
|
-
|
|
243
|
+
# Public: Configure Phaxio with your api_key and api_secret
|
|
244
|
+
#
|
|
245
|
+
# Examples
|
|
246
|
+
#
|
|
247
|
+
# Phaxio.config do |config|
|
|
248
|
+
# config.api_key = "12345678910"
|
|
249
|
+
# config.api_secret = "10987654321"
|
|
250
|
+
# end
|
|
251
|
+
#
|
|
252
|
+
# Returns nothing.
|
|
253
|
+
def self.config
|
|
254
|
+
yield(self)
|
|
143
255
|
end
|
|
144
256
|
|
|
257
|
+
extend Client
|
|
258
|
+
extend Config
|
|
145
259
|
end
|
data/lib/phaxio/version.rb
CHANGED
data/lib/phaxio.rb
CHANGED
data/phaxio.gemspec
CHANGED
|
@@ -4,9 +4,9 @@ require File.expand_path('../lib/phaxio/version', __FILE__)
|
|
|
4
4
|
Gem::Specification.new do |gem|
|
|
5
5
|
gem.authors = ["Sean Behan", "Brett Chalupa"]
|
|
6
6
|
gem.email = ["inbox@seanbehan.com", "brettchalupa@gmail.com"]
|
|
7
|
-
gem.description = %q{A Ruby Gem for interacting with Phaxio's JSON API}
|
|
7
|
+
gem.description = %q{A Ruby Gem for interacting with Phaxio's JSON API. Currently, not all of the Phaxio API calls are supported. The essentials are in place and more will be coming with future versions of this gem.}
|
|
8
8
|
gem.summary = %q{A Ruby Gem for interacting with Phaxio's JSON API}
|
|
9
|
-
gem.homepage = "http://gristmill.io"
|
|
9
|
+
gem.homepage = "http://www.gristmill.io/posts/17-introducing-the-phaxio-gem-an-easy-way-to-use-phaxio-with-ruby"
|
|
10
10
|
|
|
11
11
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
12
12
|
gem.files = `git ls-files`.split("\n")
|
|
@@ -15,7 +15,10 @@ Gem::Specification.new do |gem|
|
|
|
15
15
|
gem.require_paths = ["lib"]
|
|
16
16
|
gem.version = Phaxio::VERSION
|
|
17
17
|
|
|
18
|
-
gem.add_runtime_dependency
|
|
19
|
-
|
|
20
|
-
gem.add_development_dependency
|
|
18
|
+
gem.add_runtime_dependency "httmultiparty"
|
|
19
|
+
|
|
20
|
+
gem.add_development_dependency 'bundler'
|
|
21
|
+
gem.add_development_dependency 'fakeweb', '~> 1.3'
|
|
22
|
+
gem.add_development_dependency 'rake', '~> 10'
|
|
23
|
+
gem.add_development_dependency 'minitest', '~> 5'
|
|
21
24
|
end
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
}
|
|
Binary file
|
data/test/test_helper.rb
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
$:<<(".")
|
|
2
|
-
require
|
|
2
|
+
require 'minitest/autorun'
|
|
3
|
+
|
|
3
4
|
require "fakeweb"
|
|
4
5
|
require "lib/phaxio"
|
|
5
6
|
|
|
7
|
+
Phaxio.config do |config|
|
|
8
|
+
config.api_key = "12345678910"
|
|
9
|
+
config.api_secret = "10987654321"
|
|
10
|
+
end
|
|
11
|
+
|
|
6
12
|
FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/send",
|
|
7
13
|
:body => File.open("test/support/responses/send_success.json").read,
|
|
8
14
|
:content_type => "application/json")
|
|
@@ -15,6 +21,26 @@ FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/testReceive",
|
|
|
15
21
|
:body => File.open("test/support/responses/test_receive.json").read,
|
|
16
22
|
:content_type => "application/json")
|
|
17
23
|
|
|
24
|
+
FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/provisionNumber",
|
|
25
|
+
:body => File.open("test/support/responses/provision_number.json").read,
|
|
26
|
+
:content_type => "application/json")
|
|
27
|
+
|
|
28
|
+
FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/releaseNumber",
|
|
29
|
+
:body => File.open("test/support/responses/release_number.json").read,
|
|
30
|
+
:content_type => "application/json")
|
|
31
|
+
|
|
32
|
+
FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/numberList",
|
|
33
|
+
:body => File.open("test/support/responses/list_numbers.json").read,
|
|
34
|
+
:content_type => "application/json")
|
|
35
|
+
|
|
36
|
+
FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/faxFile",
|
|
37
|
+
:body => File.open("test/support/responses/test.pdf").read,
|
|
38
|
+
:content_type => "application/pdf")
|
|
39
|
+
|
|
40
|
+
FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/faxList",
|
|
41
|
+
:body => File.open("test/support/responses/list_faxes.json").read,
|
|
42
|
+
:content_type => "application/json")
|
|
43
|
+
|
|
18
44
|
FakeWeb.register_uri(:post, "https://api.phaxio.com/v1/faxStatus",
|
|
19
45
|
:body => File.open("test/support/responses/fax_status_success.json").read,
|
|
20
46
|
:content_type => "application/json")
|
data/test/test_phaxio.rb
CHANGED
|
@@ -1,49 +1,70 @@
|
|
|
1
1
|
require_relative "test_helper"
|
|
2
2
|
|
|
3
|
-
class TestPhaxio < Test
|
|
4
|
-
def setup
|
|
5
|
-
@client = Phaxio.client.config do |config|
|
|
6
|
-
config.api_key = 10987654321
|
|
7
|
-
config.api_secret = 12345678910
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
3
|
+
class TestPhaxio < MiniTest::Test
|
|
11
4
|
def test_config
|
|
12
|
-
assert_equal
|
|
13
|
-
assert_equal
|
|
5
|
+
assert_equal "12345678910", Phaxio.api_key
|
|
6
|
+
assert_equal "10987654321", Phaxio.api_secret
|
|
14
7
|
end
|
|
15
8
|
|
|
16
9
|
def test_initialize
|
|
17
|
-
assert_instance_of Phaxio::Client, @client
|
|
18
10
|
end
|
|
19
11
|
|
|
20
12
|
def test_send_fax
|
|
21
|
-
@response =
|
|
13
|
+
@response = Phaxio.send_fax(to: "0123456789", filename: "test.pdf")
|
|
22
14
|
assert_equal true, @response["success"]
|
|
23
15
|
assert_equal "Fax queued for sending", @response["message"]
|
|
24
16
|
assert_equal 1234, @response["faxId"]
|
|
25
17
|
end
|
|
26
18
|
|
|
27
19
|
def test_test_receive
|
|
28
|
-
@response =
|
|
20
|
+
@response = Phaxio.test_receive(filename: "test_file.pdf")
|
|
29
21
|
assert_equal true, @response["success"]
|
|
30
22
|
assert_equal "Test fax received from 234567890. Calling back now...", @response["message"]
|
|
31
23
|
end
|
|
32
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
|
+
|
|
33
54
|
def test_get_fax_status
|
|
34
|
-
@response =
|
|
55
|
+
@response = Phaxio.get_fax_status(id: 123456)
|
|
35
56
|
assert_equal true, @response["success"]
|
|
36
57
|
assert_equal "Retrieved fax successfully", @response["message"]
|
|
37
58
|
end
|
|
38
59
|
|
|
39
60
|
def test_cancel_fax
|
|
40
|
-
@response =
|
|
61
|
+
@response = Phaxio.cancel_fax(id: 123456)
|
|
41
62
|
assert_equal true, @response["success"]
|
|
42
63
|
assert_equal "Fax canceled successfully.", @response["message"]
|
|
43
64
|
end
|
|
44
65
|
|
|
45
66
|
def test_get_account_status
|
|
46
|
-
@response =
|
|
67
|
+
@response = Phaxio.get_account_status
|
|
47
68
|
assert_equal true, @response["success"]
|
|
48
69
|
assert_equal "Account status retrieved successfully", @response["message"]
|
|
49
70
|
assert_equal 120, @response["data"]["faxes_sent_this_month"]
|
metadata
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: phaxio
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.4.1
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Sean Behan
|
|
@@ -10,57 +9,81 @@ authors:
|
|
|
10
9
|
autorequire:
|
|
11
10
|
bindir: bin
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
12
|
+
date: 2015-12-16 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
|
-
name:
|
|
15
|
+
name: httmultiparty
|
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
|
18
|
-
none: false
|
|
19
17
|
requirements:
|
|
20
|
-
- -
|
|
18
|
+
- - ">="
|
|
21
19
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: 0
|
|
20
|
+
version: '0'
|
|
23
21
|
type: :runtime
|
|
24
22
|
prerelease: false
|
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
-
none: false
|
|
27
24
|
requirements:
|
|
28
|
-
- -
|
|
25
|
+
- - ">="
|
|
29
26
|
- !ruby/object:Gem::Version
|
|
30
|
-
version: 0
|
|
27
|
+
version: '0'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: bundler
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '0'
|
|
35
|
+
type: :development
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '0'
|
|
31
42
|
- !ruby/object:Gem::Dependency
|
|
32
43
|
name: fakeweb
|
|
33
44
|
requirement: !ruby/object:Gem::Requirement
|
|
34
|
-
none: false
|
|
35
45
|
requirements:
|
|
36
|
-
- - ~>
|
|
46
|
+
- - "~>"
|
|
37
47
|
- !ruby/object:Gem::Version
|
|
38
|
-
version: 1.3
|
|
48
|
+
version: '1.3'
|
|
39
49
|
type: :development
|
|
40
50
|
prerelease: false
|
|
41
51
|
version_requirements: !ruby/object:Gem::Requirement
|
|
42
|
-
none: false
|
|
43
52
|
requirements:
|
|
44
|
-
- - ~>
|
|
53
|
+
- - "~>"
|
|
45
54
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 1.3
|
|
55
|
+
version: '1.3'
|
|
47
56
|
- !ruby/object:Gem::Dependency
|
|
48
57
|
name: rake
|
|
49
58
|
requirement: !ruby/object:Gem::Requirement
|
|
50
|
-
none: false
|
|
51
59
|
requirements:
|
|
52
|
-
- - ~>
|
|
60
|
+
- - "~>"
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '10'
|
|
63
|
+
type: :development
|
|
64
|
+
prerelease: false
|
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - "~>"
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '10'
|
|
70
|
+
- !ruby/object:Gem::Dependency
|
|
71
|
+
name: minitest
|
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - "~>"
|
|
53
75
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
76
|
+
version: '5'
|
|
55
77
|
type: :development
|
|
56
78
|
prerelease: false
|
|
57
79
|
version_requirements: !ruby/object:Gem::Requirement
|
|
58
|
-
none: false
|
|
59
80
|
requirements:
|
|
60
|
-
- - ~>
|
|
81
|
+
- - "~>"
|
|
61
82
|
- !ruby/object:Gem::Version
|
|
62
|
-
version:
|
|
63
|
-
description: A Ruby Gem for interacting with Phaxio's JSON API
|
|
83
|
+
version: '5'
|
|
84
|
+
description: A Ruby Gem for interacting with Phaxio's JSON API. Currently, not all
|
|
85
|
+
of the Phaxio API calls are supported. The essentials are in place and more will
|
|
86
|
+
be coming with future versions of this gem.
|
|
64
87
|
email:
|
|
65
88
|
- inbox@seanbehan.com
|
|
66
89
|
- brettchalupa@gmail.com
|
|
@@ -68,7 +91,9 @@ executables: []
|
|
|
68
91
|
extensions: []
|
|
69
92
|
extra_rdoc_files: []
|
|
70
93
|
files:
|
|
71
|
-
- .gitignore
|
|
94
|
+
- ".gitignore"
|
|
95
|
+
- ".ruby-version"
|
|
96
|
+
- ".travis.yml"
|
|
72
97
|
- Gemfile
|
|
73
98
|
- LICENSE
|
|
74
99
|
- README.md
|
|
@@ -77,46 +102,40 @@ files:
|
|
|
77
102
|
- lib/phaxio/client.rb
|
|
78
103
|
- lib/phaxio/version.rb
|
|
79
104
|
- phaxio.gemspec
|
|
80
|
-
- test/support/account_status.json
|
|
81
105
|
- test/support/responses/account_status.json
|
|
82
106
|
- test/support/responses/cancel_success.json
|
|
83
107
|
- test/support/responses/fax_status_success.json
|
|
108
|
+
- test/support/responses/list_faxes.json
|
|
109
|
+
- test/support/responses/list_numbers.json
|
|
110
|
+
- test/support/responses/provision_number.json
|
|
111
|
+
- test/support/responses/release_number.json
|
|
84
112
|
- test/support/responses/send_failure.json
|
|
85
113
|
- test/support/responses/send_success.json
|
|
114
|
+
- test/support/responses/test.pdf
|
|
86
115
|
- test/support/responses/test_receive.json
|
|
87
116
|
- test/test_helper.rb
|
|
88
117
|
- test/test_phaxio.rb
|
|
89
|
-
homepage: http://gristmill.io
|
|
118
|
+
homepage: http://www.gristmill.io/posts/17-introducing-the-phaxio-gem-an-easy-way-to-use-phaxio-with-ruby
|
|
90
119
|
licenses: []
|
|
120
|
+
metadata: {}
|
|
91
121
|
post_install_message:
|
|
92
122
|
rdoc_options: []
|
|
93
123
|
require_paths:
|
|
94
124
|
- lib
|
|
95
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
|
-
none: false
|
|
97
126
|
requirements:
|
|
98
|
-
- -
|
|
127
|
+
- - ">="
|
|
99
128
|
- !ruby/object:Gem::Version
|
|
100
129
|
version: '0'
|
|
101
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
|
-
none: false
|
|
103
131
|
requirements:
|
|
104
|
-
- -
|
|
132
|
+
- - ">="
|
|
105
133
|
- !ruby/object:Gem::Version
|
|
106
134
|
version: '0'
|
|
107
135
|
requirements: []
|
|
108
136
|
rubyforge_project:
|
|
109
|
-
rubygems_version:
|
|
137
|
+
rubygems_version: 2.4.6
|
|
110
138
|
signing_key:
|
|
111
|
-
specification_version:
|
|
139
|
+
specification_version: 4
|
|
112
140
|
summary: A Ruby Gem for interacting with Phaxio's JSON API
|
|
113
|
-
test_files:
|
|
114
|
-
- test/support/account_status.json
|
|
115
|
-
- test/support/responses/account_status.json
|
|
116
|
-
- test/support/responses/cancel_success.json
|
|
117
|
-
- test/support/responses/fax_status_success.json
|
|
118
|
-
- test/support/responses/send_failure.json
|
|
119
|
-
- test/support/responses/send_success.json
|
|
120
|
-
- test/support/responses/test_receive.json
|
|
121
|
-
- test/test_helper.rb
|
|
122
|
-
- test/test_phaxio.rb
|
|
141
|
+
test_files: []
|