pamfaxr 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2010 Voxeo Corporation
3
+ Copyright (c) 2011 Voxeo Corporation
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  PamFaxr
2
2
  =======
3
3
 
4
- Ruby library for sending faxes via the [PamFax](http://pamfax.com) Simple API.
4
+ Ruby library for sending faxes via the [PamFax](http://www.pamfax.biz/en/partners/tropo/) Simple API.
5
5
 
6
6
  Overview
7
7
  --------
8
8
 
9
- You may send faxes using the PamFax API. See the [PamFax Developer](http://www.pamfax.biz/en/extensions/developers/) page for more details and how to get your developer key.
9
+ You may send faxes using the PamFax API. See the [PamFax Developer](http://www.pamfax.biz/en/partners/tropo/) page for more details and how to get your developer key.
10
10
 
11
11
  Requirements
12
12
  ------------
@@ -20,26 +20,30 @@ Example
20
20
  -------
21
21
 
22
22
  # Create a new PamFaxr object
23
- pamfaxr = PamFaxr.new :base_uri => 'https://sandbox-api.pamfax.biz',
24
- :key => 'your_api_key',
25
- :secret => 'your_api_secret',
26
- :username => 'your_username',
23
+
24
+ pamfaxr = PamFaxr.new :username => 'your_username',
27
25
  :password => 'your_password'
26
+
28
27
  # Create a new FaxJob
29
28
  pamfaxr.create_fax_job
29
+
30
30
  # Add the cover sheet
31
31
  covers = pamfaxr.list_available_covers
32
32
  pamfaxr.set_cover(covers['Covers']['content'][1]['id'], 'Foobar is here!')
33
+
33
34
  # Add files
34
- pamfaxr.add_remote_file('https://s3.amazonaws.com/pamfax-test/R-intro.pdf')
35
- pamfaxr.add_file('examples/R-intro.pdf')
35
+ pamfaxr.add_remote_file('https://s3.amazonaws.com/pamfax-test/Tropo.pdf')
36
+ pamfaxr.add_file('examples/Tropo.pdf')
37
+
36
38
  # Add a recipient
37
39
  pamfaxr.add_recipient('+14155551212')
40
+
38
41
  # Loop until the fax is ready to send
39
42
  loop do
40
43
  fax_state = pamfaxr.get_state
41
44
  break if fax_state['FaxContainer']['state'] == 'ready_to_send'
42
45
  sleep 5
43
46
  end
47
+
44
48
  # Send the fax
45
49
  pamfaxr.send_fax
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
Binary file
data/examples/example.rb CHANGED
@@ -2,15 +2,12 @@ require 'rubygems'
2
2
  require 'lib/pamfaxr'
3
3
  require 'awesome_print'
4
4
 
5
- PAMFAX_URI = 'https://sandbox-api.pamfax.biz'
6
- PAMFAX_KEY = 'your_key'
7
- PAMFAX_SECRET = 'your_secret'
8
- PAMFAX_USERNAME = 'your_username'
9
- PAMFAX_PASSWORD = 'your_password'
5
+ PAMFAX_URI = 'https://api.pamfax.biz/'
6
+ PAMFAX_USERNAME = 'username'
7
+ PAMFAX_PASSWORD = 'password'
10
8
 
9
+ # You may also specificy a custom :api_key and :api_secret, or it uses the default
11
10
  pamfaxr = PamFaxr.new :base_uri => PAMFAX_URI,
12
- :key => PAMFAX_KEY,
13
- :secret => PAMFAX_SECRET,
14
11
  :username => PAMFAX_USERNAME,
15
12
  :password => PAMFAX_PASSWORD
16
13
 
@@ -31,11 +28,11 @@ ap pamfaxr.set_cover(covers['Covers']['content'][1]['id'], 'Foobar is here!')
31
28
 
32
29
  ap 'Adding a remote file'
33
30
  ap '*'*10
34
- ap pamfaxr.add_remote_file('https://s3.amazonaws.com/pamfax-test/R-intro.pdf')
31
+ ap pamfaxr.add_remote_file('https://s3.amazonaws.com/pamfax-test/Tropo.pdf')
35
32
 
36
33
  ap 'Adding a local file'
37
34
  ap '*'*10
38
- file = pamfaxr.add_file('examples/R-intro.pdf')
35
+ file = pamfaxr.add_file('examples/Tropo.pdf')
39
36
  ap file
40
37
 
41
38
  ap 'Removing a file'
@@ -1,6 +1,6 @@
1
1
  class PamFaxr
2
2
  class FaxJob
3
- require 'awesome_print'
3
+
4
4
  ##
5
5
  # Instantiates the FaxJob class
6
6
  #
@@ -133,7 +133,7 @@ class PamFaxr
133
133
  # @return [Hash] the result of the request to add a file
134
134
  #
135
135
  # @example adding a remote file
136
- # pamfaxr.add_remote_file('https://s3.amazonaws.com/pamfax-test/R-intro.pdf')
136
+ # pamfaxr.add_remote_file('https://s3.amazonaws.com/pamfax-test/Tropo.pdf')
137
137
  #
138
138
  # returns:
139
139
  #
@@ -144,7 +144,7 @@ class PamFaxr
144
144
  # "message" => ""
145
145
  # },
146
146
  # "FaxContainerFile" => {
147
- # "name" => "R-intro.pdf",
147
+ # "name" => "Tropo.pdf",
148
148
  # "file_order" => 0,
149
149
  # "ext" => "pdf",
150
150
  # "file_uuid" => "CwPx31xjl9k7Cp",
@@ -288,7 +288,7 @@ class PamFaxr
288
288
  # "type" => "list",
289
289
  # "content" => [
290
290
  # [0] {
291
- # "name" => "R-intro.pdf",
291
+ # "name" => "Tropo.pdf",
292
292
  # "size" => 646768,
293
293
  # "extension" => "pdf",
294
294
  # "uuid" => "CwPx31xjl9k7Cp",
@@ -699,7 +699,8 @@ class PamFaxr
699
699
  # @return [Hash] the result of the request
700
700
  def get(resource)
701
701
  begin
702
- JSON.parse @http.get(resource, { 'Content-Type' => 'application/json' }).body
702
+ body = @http.get(resource, { 'Content-Type' => 'application/json' }).body
703
+ JSON.parse body
703
704
  rescue => error
704
705
  end
705
706
  end
@@ -725,21 +726,23 @@ class PamFaxr
725
726
  # Creates an instance of the PamFax class
726
727
  #
727
728
  # @param [Hash] params the options for instantiating a PamFax class
728
- # @option params [optionsl, String] :base_uri the URI of the PamFax API, it defaults to https://api.pamfax.biz
729
- # @option params [String] :key the PamFax API key you have been assigned
730
- # @option params [String] :secret the PamFax API secret you have been assigned
731
729
  # @option params [String] :username the PamFax username you are going to use to send faxes
732
730
  # @option params [String] :password the PamFax password you are going to use to send faxes
731
+ # @option params [optionsl, String] :base_uri the URI of the PamFax API, it defaults to https://api.pamfax.biz
732
+ # @option params [optional, String] :api_key the PamFax API key you have been assigned
733
+ # @option params [optional, String] :api_secret the PamFax API secret you have been assigned
733
734
  #
734
735
  # @return [Object] the instantiated FaxJob class
735
736
  #
736
737
  # @example create a new PamFax object
737
738
  # pamfaxr = PamFax.new({ :key => 'your_api_key', :secret => 'your_api_secret' })
738
739
  def initialize(options={})
739
- base_uri = options[:base_uri] || "https://api.pamfax.biz"
740
+ base_uri = options[:base_uri] || "https://api.pamfax.biz"
741
+ api_key = options[:api_key] || "tropo_developer"
742
+ api_secret = options[:api_secret] || "7xGi0xAqcg3YXw"
740
743
 
741
744
  options.merge!({ :http => create_http(URI.parse(base_uri)),
742
- :api_credentials => "?apikey=#{options[:key]}&apisecret=#{options[:secret]}&apioutputformat=API_FORMAT_JSON" })
745
+ :api_credentials => "?apikey=#{api_key}&apisecret=#{api_secret}&apioutputformat=API_FORMAT_JSON" })
743
746
  options[:api_credentials] = options[:api_credentials] + "&usertoken=#{get_user_token(options)}"
744
747
 
745
748
  @fax_job = FaxJob.new options
@@ -782,7 +785,8 @@ class PamFaxr
782
785
  # @return [Object] the instantiated FaxJob class
783
786
  def verify_user(options={})
784
787
  resource = "/Session/VerifyUser/#{options[:api_credentials]}&username=#{options[:username]}&password=#{options[:password]}"
785
- JSON.parse options[:http].get(resource).body
788
+ body = options[:http].get(resource).body
789
+ JSON.parse body
786
790
  end
787
791
 
788
792
  ##
data/pamfaxr.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pamfaxr}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jason Goecke"]
12
- s.date = %q{2011-01-26}
12
+ s.date = %q{2011-02-10}
13
13
  s.description = %q{Ruby library for the FaxJob portion of the PamFax API.}
14
14
  s.email = %q{jsgoecke@voxeo.com}
15
15
  s.extra_rdoc_files = [
@@ -17,15 +17,13 @@ Gem::Specification.new do |s|
17
17
  "README.md"
18
18
  ]
19
19
  s.files = [
20
- ".bundle/config",
21
- ".document",
22
20
  "Gemfile",
23
21
  "Gemfile.lock",
24
22
  "LICENSE",
25
23
  "README.md",
26
24
  "Rakefile",
27
25
  "VERSION",
28
- "examples/R-intro.pdf",
26
+ "examples/Tropo.pdf",
29
27
  "examples/example.rb",
30
28
  "lib/pamfaxr.rb",
31
29
  "lib/pamfaxr/multipart.rb",
@@ -39,7 +37,7 @@ Gem::Specification.new do |s|
39
37
  s.homepage = %q{http://github.com/tropo/pamfaxr}
40
38
  s.licenses = ["MIT"]
41
39
  s.require_paths = ["lib"]
42
- s.rubygems_version = %q{1.3.7}
40
+ s.rubygems_version = %q{1.3.6}
43
41
  s.summary = %q{Ruby library for the PamFax API.}
44
42
  s.test_files = [
45
43
  "examples/example.rb",
@@ -51,7 +49,7 @@ Gem::Specification.new do |s|
51
49
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
50
  s.specification_version = 3
53
51
 
54
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
55
53
  s.add_runtime_dependency(%q<mime-types>, [">= 0"])
56
54
  s.add_runtime_dependency(%q<json>, [">= 0"])
57
55
  s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
data/spec/pamfaxr_spec.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- PAMFAX_URI = 'https://sandbox-api.pamfax.biz'
4
- PAMFAX_KEY = 'name'
5
- PAMFAX_SECRET = 'abd123'
6
- PAMFAX_USERNAME = 'fooey'
7
- PAMFAX_PASSWORD = 'foobar'
3
+ PAMFAX_URI = 'https://sandbox-api.pamfax.biz'
4
+ PAMFAX_API_KEY = 'name'
5
+ PAMFAX_API_SECRET = 'abd123'
6
+ PAMFAX_USERNAME = 'fooey'
7
+ PAMFAX_PASSWORD = 'foobar'
8
8
 
9
9
  FakeWeb.allow_net_connect = false
10
10
 
@@ -178,7 +178,7 @@ describe "PamFaxr" do
178
178
  "message" => ""
179
179
  },
180
180
  "FaxContainerFile" => {
181
- "name" => "R-intro.pdf",
181
+ "name" => "Tropo.pdf",
182
182
  "file_order" => 0,
183
183
  "ext" => "pdf",
184
184
  "file_uuid" => "OQskZYr9D0MANw",
@@ -194,7 +194,7 @@ describe "PamFaxr" do
194
194
  "message" => ""
195
195
  },
196
196
  "FaxContainerFile" => {
197
- "name" => "R-intro.pdf",
197
+ "name" => "Tropo.pdf",
198
198
  "file_order" => 0,
199
199
  "ext" => "pdf",
200
200
  "file_uuid" => "OuH2JbbGKhDp8o",
@@ -221,7 +221,7 @@ describe "PamFaxr" do
221
221
  "type" => "list",
222
222
  "content" => [
223
223
  {
224
- "name" => "R-intro.pdf",
224
+ "name" => "Tropo.pdf",
225
225
  "size" => 646768,
226
226
  "extension" => "pdf",
227
227
  "uuid" => "aMzeebWS9O8GKz",
@@ -231,7 +231,7 @@ describe "PamFaxr" do
231
231
  "created" => "2011-01-17 14:55:57"
232
232
  },
233
233
  {
234
- "name" => "examples/R-intro.pdf",
234
+ "name" => "examples/Tropo.pdf",
235
235
  "size" => 646768,
236
236
  "extension" => "pdf",
237
237
  "uuid" => "BVMJzRmu1zAlSZ",
@@ -308,9 +308,13 @@ describe "PamFaxr" do
308
308
  }
309
309
  }
310
310
 
311
- # Addresses
312
311
  FakeWeb.register_uri(:get,
313
- "https://sandbox-api.pamfax.biz/Session/VerifyUser/?apikey=#{PAMFAX_KEY}&apisecret=#{PAMFAX_SECRET}&apioutputformat=API_FORMAT_JSON&username=#{PAMFAX_USERNAME}&password=#{PAMFAX_PASSWORD}",
312
+ "https://sandbox-api.pamfax.biz/Session/VerifyUser/?apikey=#{PAMFAX_API_KEY}&apisecret=#{PAMFAX_API_SECRET}&apioutputformat=API_FORMAT_JSON&username=#{PAMFAX_USERNAME}&password=#{PAMFAX_PASSWORD}",
313
+ :body => @user_found.to_json,
314
+ :content_type => "application/json")
315
+
316
+ FakeWeb.register_uri(:get,
317
+ "https://api.pamfax.biz/Session/VerifyUser/?apikey=tropo_developer&apisecret=7xGi0xAqcg3YXw&apioutputformat=API_FORMAT_JSON&username=fooey&password=looey",
314
318
  :body => @user_found.to_json,
315
319
  :content_type => "application/json")
316
320
 
@@ -357,7 +361,7 @@ describe "PamFaxr" do
357
361
  :status => ["200", "OK"])
358
362
 
359
363
  FakeWeb.register_uri(:get,
360
- "https://sandbox-api.pamfax.biz/FaxJob/AddRemoteFile?apikey=name&apisecret=abd123&apioutputformat=API_FORMAT_JSON&usertoken=m3cv0d9gqb69taajcu76nqv5eccht76t&url=https://s3.amazonaws.com/pamfax-test/R-intro.pdf",
364
+ "https://sandbox-api.pamfax.biz/FaxJob/AddRemoteFile?apikey=name&apisecret=abd123&apioutputformat=API_FORMAT_JSON&usertoken=m3cv0d9gqb69taajcu76nqv5eccht76t&url=https://s3.amazonaws.com/pamfax-test/Tropo.pdf",
361
365
  :body => @page.to_json,
362
366
  :content_type => "application/json",
363
367
  :status => ["200", "OK"])
@@ -399,11 +403,11 @@ describe "PamFaxr" do
399
403
  :status => ["200", "OK"])
400
404
 
401
405
  # Our testing URI
402
- @pamfaxr = PamFaxr.new :base_uri => PAMFAX_URI,
403
- :key => PAMFAX_KEY,
404
- :secret => PAMFAX_SECRET,
405
- :username => PAMFAX_USERNAME,
406
- :password => PAMFAX_PASSWORD
406
+ @pamfaxr = PamFaxr.new :base_uri => PAMFAX_URI,
407
+ :api_key => PAMFAX_API_KEY,
408
+ :api_secret => PAMFAX_API_SECRET,
409
+ :username => PAMFAX_USERNAME,
410
+ :password => PAMFAX_PASSWORD
407
411
 
408
412
  end
409
413
 
@@ -411,13 +415,19 @@ describe "PamFaxr" do
411
415
  @pamfaxr.instance_of?(PamFaxr).should == true
412
416
  end
413
417
 
418
+ it "should create an instance of PamFax without the base_uri, api_key or api_secret included" do
419
+ pamfaxr = PamFaxr.new :username => 'fooey',
420
+ :password => 'looey'
421
+ pamfaxr.instance_of?(PamFaxr).should == true
422
+ end
423
+
414
424
  it "should get an error if invalid user details are requested" do
415
425
  begin
416
- pamfax = PamFaxr.new :base_uri => PAMFAX_URI,
417
- :key => 'tropo',
418
- :secret => 'abc123',
419
- :username => 'fooey',
420
- :password => 'looey'
426
+ pamfax = PamFaxr.new :base_uri => PAMFAX_URI,
427
+ :api_key => 'tropo',
428
+ :api_secret => 'abc123',
429
+ :username => 'fooey',
430
+ :password => 'looey'
421
431
  rescue => e
422
432
  e.to_s.should == "Unknown user name or incorrect password"
423
433
  end
@@ -452,8 +462,8 @@ describe "PamFaxr" do
452
462
  end
453
463
 
454
464
  it "should add a file to the fax job" do
455
- @pamfaxr.add_remote_file('https://s3.amazonaws.com/pamfax-test/R-intro.pdf').should == @page
456
- @pamfaxr.add_file('examples/R-intro.pdf').should == @local_file_upload
465
+ @pamfaxr.add_remote_file('https://s3.amazonaws.com/pamfax-test/Tropo.pdf').should == @page
466
+ @pamfaxr.add_file('examples/Tropo.pdf').should == @local_file_upload
457
467
  end
458
468
 
459
469
  it "should list the available fax cover templates" do
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pamfaxr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 0
9
- - 1
10
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
11
10
  platform: ruby
12
11
  authors:
13
12
  - Jason Goecke
@@ -15,99 +14,87 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-01-26 00:00:00 -08:00
17
+ date: 2011-02-10 00:00:00 +00:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  type: :runtime
23
- prerelease: false
24
22
  name: mime-types
25
23
  version_requirements: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
25
  - - ">="
29
26
  - !ruby/object:Gem::Version
30
- hash: 3
31
27
  segments:
32
28
  - 0
33
29
  version: "0"
34
30
  requirement: *id001
31
+ prerelease: false
35
32
  - !ruby/object:Gem::Dependency
36
33
  type: :runtime
37
- prerelease: false
38
34
  name: json
39
35
  version_requirements: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
36
  requirements:
42
37
  - - ">="
43
38
  - !ruby/object:Gem::Version
44
- hash: 3
45
39
  segments:
46
40
  - 0
47
41
  version: "0"
48
42
  requirement: *id002
43
+ prerelease: false
49
44
  - !ruby/object:Gem::Dependency
50
45
  type: :development
51
- prerelease: false
52
46
  name: rspec
53
47
  version_requirements: &id003 !ruby/object:Gem::Requirement
54
- none: false
55
48
  requirements:
56
49
  - - ~>
57
50
  - !ruby/object:Gem::Version
58
- hash: 3
59
51
  segments:
60
52
  - 2
61
53
  - 3
62
54
  - 0
63
55
  version: 2.3.0
64
56
  requirement: *id003
57
+ prerelease: false
65
58
  - !ruby/object:Gem::Dependency
66
59
  type: :development
67
- prerelease: false
68
60
  name: bundler
69
61
  version_requirements: &id004 !ruby/object:Gem::Requirement
70
- none: false
71
62
  requirements:
72
63
  - - ~>
73
64
  - !ruby/object:Gem::Version
74
- hash: 23
75
65
  segments:
76
66
  - 1
77
67
  - 0
78
68
  - 0
79
69
  version: 1.0.0
80
70
  requirement: *id004
71
+ prerelease: false
81
72
  - !ruby/object:Gem::Dependency
82
73
  type: :development
83
- prerelease: false
84
74
  name: jeweler
85
75
  version_requirements: &id005 !ruby/object:Gem::Requirement
86
- none: false
87
76
  requirements:
88
77
  - - ~>
89
78
  - !ruby/object:Gem::Version
90
- hash: 7
91
79
  segments:
92
80
  - 1
93
81
  - 5
94
82
  - 2
95
83
  version: 1.5.2
96
84
  requirement: *id005
85
+ prerelease: false
97
86
  - !ruby/object:Gem::Dependency
98
87
  type: :development
99
- prerelease: false
100
88
  name: rcov
101
89
  version_requirements: &id006 !ruby/object:Gem::Requirement
102
- none: false
103
90
  requirements:
104
91
  - - ">="
105
92
  - !ruby/object:Gem::Version
106
- hash: 3
107
93
  segments:
108
94
  - 0
109
95
  version: "0"
110
96
  requirement: *id006
97
+ prerelease: false
111
98
  description: Ruby library for the FaxJob portion of the PamFax API.
112
99
  email: jsgoecke@voxeo.com
113
100
  executables: []
@@ -118,15 +105,13 @@ extra_rdoc_files:
118
105
  - LICENSE
119
106
  - README.md
120
107
  files:
121
- - .bundle/config
122
- - .document
123
108
  - Gemfile
124
109
  - Gemfile.lock
125
110
  - LICENSE
126
111
  - README.md
127
112
  - Rakefile
128
113
  - VERSION
129
- - examples/R-intro.pdf
114
+ - examples/Tropo.pdf
130
115
  - examples/example.rb
131
116
  - lib/pamfaxr.rb
132
117
  - lib/pamfaxr/multipart.rb
@@ -146,27 +131,23 @@ rdoc_options: []
146
131
  require_paths:
147
132
  - lib
148
133
  required_ruby_version: !ruby/object:Gem::Requirement
149
- none: false
150
134
  requirements:
151
135
  - - ">="
152
136
  - !ruby/object:Gem::Version
153
- hash: 3
154
137
  segments:
155
138
  - 0
156
139
  version: "0"
157
140
  required_rubygems_version: !ruby/object:Gem::Requirement
158
- none: false
159
141
  requirements:
160
142
  - - ">="
161
143
  - !ruby/object:Gem::Version
162
- hash: 3
163
144
  segments:
164
145
  - 0
165
146
  version: "0"
166
147
  requirements: []
167
148
 
168
149
  rubyforge_project:
169
- rubygems_version: 1.3.7
150
+ rubygems_version: 1.3.6
170
151
  signing_key:
171
152
  specification_version: 3
172
153
  summary: Ruby library for the PamFax API.
data/.bundle/config DELETED
@@ -1,2 +0,0 @@
1
- ---
2
- BUNDLE_DISABLE_SHARED_GEMS: "1"
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/examples/R-intro.pdf DELETED
Binary file