ringcentral 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  [ringcentral](http://github.com/tfe/ringcentral/)
2
2
  ========
3
3
 
4
- A Ruby library for interacting with the RingCentral [RingOut API](https://service.ringcentral.com/ringoutapi/) and (coming soon) [FaxOut API](https://service.ringcentral.com/faxoutapi/).
4
+ A Ruby library for interacting with the RingCentral [RingOut API](https://service.ringcentral.com/ringoutapi/) and [FaxOut API](https://service.ringcentral.com/faxoutapi/).
5
5
 
6
6
  Currently it is a very thin wrapper around the native RingCentral HTTP API. Eventually I would like to document and abstract away as many of the idiosyncrasies of the native API as possible.
7
7
 
@@ -152,17 +152,41 @@ The response is simply the session ID in a hash. The same response is given no m
152
152
 
153
153
  ### FaxOut
154
154
 
155
- To be implemented.
155
+ There is only one method for faxing: `send`.
156
+
157
+ RingCentral::Fax.send(username, password, extension, recipient, attachment, cover_page = 'None', cover_page_text = nil, resolution = nil, send_time = nil)
158
+
159
+ Send a fax to a given recipient with a given attachment (`File` object) using a given cover page (default is to not use a cover page). If the cover page option is set to nil, the default cover page will be used. Other cover page options exist, but RingCentral does not specify how to use them (you could experiment by putting different names in this parameter).
160
+
161
+ You can also specify text to include on the cover page, the resolution to use (possible values are `Low` and `High`), and the time to send (GMT time in the format `dd:mm:yy hh:mm`). If send time is invalid or not in the future, the fax will be sent immediately.
162
+
163
+ Credentials work the same as with the phone methods, with the exception that you can pass `nil` as the extension number, in which case the master account is used.
164
+
165
+ The response is a simple status string. Possible values are as follows:
166
+
167
+ * Successful
168
+ * Authorization failed
169
+ * Faxing is prohibited for the account
170
+ * No recipients specified
171
+ * No fax data specified
172
+ * Generic error
173
+
174
+ Note that this only indicates the status of the request to send the fax; it does not tell you anything about whether the fax was transmitted successfully or not. There is no way to check programmatically for the status of a fax. However, you will get an email with the results of the fax job at the address corresponding to the credentials/account you used to send the fax.
175
+
176
+ >> RingCentral::Fax.send('5556090455', 'qwerty', '100', '5556465589', File.new('/path/to/file.pdf'))
177
+ => "Successful"
178
+
156
179
 
157
180
 
158
181
  Todo
159
182
  ----
160
183
 
161
184
  * Be able to supply RingCentral account credentials once, up-front, rather than supplying with each API call.
162
- * Wrap up the call, status, and cancel into a Call object which maintains its state.
185
+ * Wrap up the Phone call, status, and cancel methods into a Call object which maintains its state.
163
186
  * Set Call command arguments using response from the List command, perhaps so a user could do `call(:from => :mobile)`
164
187
  * Determine how accepting the RingCentral APIs are of formatted or malformed input.
165
- * Implement the FaxOut API.
188
+ * Accept more than one recipient for faxing; allow more than one attachment.
189
+ * Allow fax send method to take a real ruby `Time` object for the send time.
166
190
  * Write tests.
167
191
 
168
192
 
data/Rakefile CHANGED
@@ -5,12 +5,13 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "ringcentral"
8
- gem.summary = %Q{A Ruby library for interacting with the RingCentral RingOut API and (coming soon) FaxOut API.}
9
- gem.description = %Q{A Ruby library for interacting with the RingCentral RingOut API and (coming soon) FaxOut API.}
8
+ gem.summary = "A Ruby library for interacting with the RingCentral RingOut API and FaxOut API."
9
+ gem.description = "A Ruby library for interacting with the RingCentral RingOut API and FaxOut API."
10
10
  gem.email = "todd@toddeichel.com"
11
11
  gem.homepage = "http://github.com/tfe/ringcentral"
12
12
  gem.authors = ["Todd Eichel"]
13
13
  gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
+ gem.add_dependency "rest-client", ">= 1.6.0"
14
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
16
  end
16
17
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -9,6 +9,35 @@ module RingCentral
9
9
  PATH = 'faxapi.asp'
10
10
  URL = [RingCentral::URL, PATH].join('/')
11
11
 
12
+ STATUS_CODES = {
13
+ 0 => 'Successful',
14
+ 1 => 'Authorization failed',
15
+ 2 => 'Faxing is prohibited for the account',
16
+ 3 => 'No recipients specified',
17
+ 4 => 'No fax data specified',
18
+ 5 => 'Generic error'
19
+ }
20
+
21
+ def self.send(username, password, extension, recipient, attachment, cover_page = 'None', cover_page_text = nil, resolution = nil, send_time = nil)
22
+
23
+ params = {
24
+ :attachment => attachment,
25
+ :recipient => recipient,
26
+ :coverpage => cover_page,
27
+ :coverpagetext => cover_page_text,
28
+ :resolution => resolution,
29
+ :sendtime => send_time
30
+ }
31
+
32
+ username_with_extension = [username, extension].compact.join('*')
33
+
34
+ response = RestClient.post(URL, params.merge(RingCentral.credentials_hash(username_with_extension, password)))
35
+
36
+ status_code = String.new(response.body).to_i # RestClient::Response casting to int behaves strangely
37
+
38
+ return STATUS_CODES[status_code]
39
+ end
40
+
12
41
  end
13
42
 
14
43
  class Phone
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ringcentral}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Todd Eichel"]
12
- s.date = %q{2010-07-31}
13
- s.description = %q{A Ruby library for interacting with the RingCentral RingOut API and (coming soon) FaxOut API.}
12
+ s.date = %q{2010-08-12}
13
+ s.description = %q{A Ruby library for interacting with the RingCentral RingOut API and FaxOut API.}
14
14
  s.email = %q{todd@toddeichel.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.rdoc_options = ["--charset=UTF-8"]
34
34
  s.require_paths = ["lib"]
35
35
  s.rubygems_version = %q{1.3.6}
36
- s.summary = %q{A Ruby library for interacting with the RingCentral RingOut API and (coming soon) FaxOut API.}
36
+ s.summary = %q{A Ruby library for interacting with the RingCentral RingOut API and FaxOut API.}
37
37
  s.test_files = [
38
38
  "test/helper.rb",
39
39
  "test/test_ringcentral.rb"
@@ -45,11 +45,14 @@ Gem::Specification.new do |s|
45
45
 
46
46
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
47
47
  s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
48
+ s.add_runtime_dependency(%q<rest-client>, [">= 1.6.0"])
48
49
  else
49
50
  s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
51
+ s.add_dependency(%q<rest-client>, [">= 1.6.0"])
50
52
  end
51
53
  else
52
54
  s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
55
+ s.add_dependency(%q<rest-client>, [">= 1.6.0"])
53
56
  end
54
57
  end
55
58
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Todd Eichel
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-31 00:00:00 -04:00
17
+ date: 2010-08-12 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -29,7 +29,21 @@ dependencies:
29
29
  version: "0"
30
30
  type: :development
31
31
  version_requirements: *id001
32
- description: A Ruby library for interacting with the RingCentral RingOut API and (coming soon) FaxOut API.
32
+ - !ruby/object:Gem::Dependency
33
+ name: rest-client
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 1
41
+ - 6
42
+ - 0
43
+ version: 1.6.0
44
+ type: :runtime
45
+ version_requirements: *id002
46
+ description: A Ruby library for interacting with the RingCentral RingOut API and FaxOut API.
33
47
  email: todd@toddeichel.com
34
48
  executables: []
35
49
 
@@ -79,7 +93,7 @@ rubyforge_project:
79
93
  rubygems_version: 1.3.6
80
94
  signing_key:
81
95
  specification_version: 3
82
- summary: A Ruby library for interacting with the RingCentral RingOut API and (coming soon) FaxOut API.
96
+ summary: A Ruby library for interacting with the RingCentral RingOut API and FaxOut API.
83
97
  test_files:
84
98
  - test/helper.rb
85
99
  - test/test_ringcentral.rb