tms_client 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 740e4fe3e5d3a7641f97b2375077d7da15c15770
4
- data.tar.gz: 91eb64507a4f94d0238f8a56cd915fdc7fbc8b62
3
+ metadata.gz: 02afad05a776d7326b6573004c848150c0f388c8
4
+ data.tar.gz: 45c99c89f356a0842fbd80f18df3ecf21b688d0d
5
5
  SHA512:
6
- metadata.gz: f7aeff2e142de5e638f6369e3730df7182b70f64ffec8c3a96456c5cbb0f29b7e96224c612fa0af599b2318f2e63c3e35a875a8130eff0ca5beb54855dfda370
7
- data.tar.gz: 852af2b4dbe19ef2f4548f17c3f957b6d4d73747f137998832854f9087059a26f42a299586e2814a4e46162977a3b53fea7aa95008041df6eb9a81add9cef7fb
6
+ metadata.gz: bb4937fc8493d31a08feecf5f3f0dab9df3b0636b8a16a550c27aaf764ee455de667dc5da02fad2ffea0cc0b1687509b6ebf0a8382eee7622e9ae49cb1459403
7
+ data.tar.gz: cc6e3ccba576297991870a2b7ab093f382ada809e71d9acb106d3559f7cd60fc946ca13dde1a1466e67507bcca47b11e7a0bb3858f83b6682cfcd64c82e0ccea
data/README.md CHANGED
@@ -54,6 +54,16 @@ message.href # "/messages/sms/87"
54
54
  message.get # <TMS::SmsMessage href=/messages/sms/87 attributes={...}>
55
55
  ```
56
56
 
57
+ ### Retrieving Inbound SMS Messages
58
+ ```ruby
59
+ client.inbound_sms_messages.get # <TMS::InboundSmsMessages href=/inbound/sms attributes={...}>
60
+ inbound_sms = client.inbound_sms_messages.collection.first # <TMS::InboundSmsMessage href=/inbound/sms/10041 attributes={...}>
61
+ inbound_sms.to # "+15559999999"
62
+ inbound_sms.from # "+15005550006"
63
+ inbound_sms.attributes # {:from=>"+15005550006", :to=>"+15559999999", :body=>"test", :command_status=>"success", :keyword_response=>"kwidjebo", :created_at=>"2014-11-05T17:15:01Z"}
64
+
65
+ ```
66
+
57
67
  ### Sending an Email Message
58
68
 
59
69
  ```ruby
@@ -221,6 +231,27 @@ commands.collection.each do |c|
221
231
  end
222
232
  ```
223
233
 
234
+ ### Viewing Command Actions
235
+ Each time a given command is executed, a command action is created.
236
+
237
+ **Note** The actions relationship does not exist on commands that have 0 command actions. Because of this, an attempt to access the command_actions attribute of a
238
+ command that has 0 command actions will result in a NoMethodError.
239
+
240
+ ```ruby
241
+ # Using the command from above
242
+ begin
243
+ command.get
244
+ command_actions = command.command_actions
245
+ command_actions.get
246
+ command_action = command_actions.collection.first
247
+ command_action.inbound_sms_message # InboundSmsMessage object that initiated this command execution
248
+ command_action.response_body # String returned by the forwarded to URL
249
+ command_action.status # HTTP Status returned by the forwarded to URL
250
+ command_action.content_type # Content-Type header returned by the forwarded to URL
251
+ rescue NoMethodError => e
252
+ # No command actions to view
253
+ end
254
+ ```
224
255
 
225
256
  Logging
226
257
  -------
@@ -111,6 +111,7 @@ module TMS::InstanceResource
111
111
  raise TMS::Errors::InvalidGet if self.new_record?
112
112
  process_response(client.get(self.href), :get) && self
113
113
  end
114
+ alias_method :get!, :get
114
115
 
115
116
  def post
116
117
  self.errors = nil
@@ -125,10 +126,18 @@ module TMS::InstanceResource
125
126
  process_response(client.put(self), :put)
126
127
  end
127
128
 
129
+ def put!
130
+ process_response(client.put(self), :put) or raise TMS::Errors::InvalidPut.new(self)
131
+ end
132
+
128
133
  def delete
129
134
  process_response(client.delete(self.href), :delete)
130
135
  end
131
136
 
137
+ def delete!
138
+ process_response(client.delete(self.href), :delete) or raise TMS::Errors::InvalidDelete.new(self)
139
+ end
140
+
132
141
  def to_s
133
142
  "<#{self.class.inspect}#{' href=' + self.href if self.href} attributes=#{@attributes.inspect}>"
134
143
  end
@@ -152,7 +161,7 @@ module TMS::InstanceResource
152
161
 
153
162
  def process_response(response, method)
154
163
  self.response = response
155
- error_class = TMS::Errors.const_get("Invalid#{method.to_s.capitalize}")
164
+ error_class = TMS::Errors.const_get("Invalid#{method.to_s.capitalize}")
156
165
  case response.status
157
166
  when 204
158
167
  return true
@@ -177,7 +186,7 @@ module TMS::InstanceResource
177
186
  def set_attributes_from_hash(hash)
178
187
  hash.reject { |k, _| k=~/^_/ }.each do |property, value|
179
188
  if self.class.collection_attributes.include?(property.to_sym)
180
- klass = self.class.custom_class_names[property] || TMS.const_get(property.to_s.capitalize)
189
+ klass = self.class.custom_class_names[property] || TMS.const_get(property.to_s.capitalize)
181
190
  @attributes[property.to_sym] = klass.new(client, nil, value)
182
191
  else
183
192
  @attributes[property.to_sym] = value
@@ -1,3 +1,3 @@
1
1
  module TMS #:nodoc:
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
@@ -43,6 +43,16 @@ describe TMS::InstanceResource do
43
43
  foo.get.should == foo
44
44
  end
45
45
 
46
+ %w{get post put delete}.each do |verb|
47
+ it "should blow up on invalid #{verb}!" do
48
+ client.should(receive(verb)).and_return(double('response', status: 404, body: "{}"))
49
+ foo = Foo.new(client, 'https://example.com/foos/1')
50
+ expect do
51
+ foo.send("#{verb}!")
52
+ end.to raise_error("TMS::Errors::Invalid#{verb.capitalize}".constantize)
53
+ end
54
+ end
55
+
46
56
  it 'it exposes its attributes hash' do
47
57
  @instance_resource.attributes.should == {}
48
58
  end
data/tms_client.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
3
  require "tms_client/version"
4
-
4
+
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "tms_client"
7
7
  s.version = TMS::VERSION
@@ -10,12 +10,10 @@ Gem::Specification.new do |s|
10
10
  s.email = ["support@govdelivery.com"]
11
11
  s.homepage = "http://govdelivery.com"
12
12
  s.summary = %q{A ruby client to interact with the GovDelivery TMS REST API.}
13
- s.description = %q{A reference implementation, written in Ruby,
14
- to interact with GovDelivery's TMS API. The client is
13
+ s.description = %q{A reference implementation, written in Ruby,
14
+ to interact with GovDelivery's TMS API. The client is
15
15
  compatible with Ruby 1.9 and 2.0. }
16
16
 
17
- # This will default active support to the latest stable version
18
- # if the variable is nil.
19
17
  s.add_runtime_dependency "activesupport"
20
18
  s.add_runtime_dependency "faraday"
21
19
  s.add_runtime_dependency "faraday_middleware"
@@ -28,6 +26,5 @@ Gem::Specification.new do |s|
28
26
  } + Dir["lib/**/*"]
29
27
 
30
28
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
31
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
32
29
  s.require_paths = ["lib"]
33
- end
30
+ end
metadata CHANGED
@@ -1,90 +1,70 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tms_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - GovDelivery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-16 00:00:00.000000000 Z
11
+ date: 2014-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: faraday_middleware
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: "A reference implementation, written in Ruby, \n to
56
- interact with GovDelivery's TMS API. The client is \n compatible
55
+ description: "A reference implementation, written in Ruby,\n to
56
+ interact with GovDelivery's TMS API. The client is\n compatible
57
57
  with Ruby 1.9 and 2.0. "
58
58
  email:
59
59
  - support@govdelivery.com
60
- executables:
61
- - autospec
62
- - htmldiff
63
- - ldiff
64
- - rake
65
- - redcarpet
66
- - rspec
67
- - tt
68
- - yard
69
- - yardoc
70
- - yri
60
+ executables: []
71
61
  extensions: []
72
62
  extra_rdoc_files: []
73
63
  files:
74
64
  - Gemfile
75
65
  - README.md
76
66
  - Rakefile
77
- - bin/autospec
78
- - bin/htmldiff
79
- - bin/ldiff
80
- - bin/rake
81
- - bin/redcarpet
82
- - bin/rspec
83
- - bin/tt
84
- - bin/yard
85
- - bin/yardoc
86
- - bin/yri
87
- - lib/tms_client.rb
67
+ - tms_client.gemspec
88
68
  - lib/tms_client/base.rb
89
69
  - lib/tms_client/client.rb
90
70
  - lib/tms_client/collection_resource.rb
@@ -121,6 +101,7 @@ files:
121
101
  - lib/tms_client/util/core_ext.rb
122
102
  - lib/tms_client/util/hal_link_parser.rb
123
103
  - lib/tms_client/version.rb
104
+ - lib/tms_client.rb
124
105
  - spec/client_spec.rb
125
106
  - spec/command_types_spec.rb
126
107
  - spec/email_message_spec.rb
@@ -142,7 +123,6 @@ files:
142
123
  - spec/tms_client_spec.rb
143
124
  - spec/voice_message_spec.rb
144
125
  - spec/voice_messages_spec.rb
145
- - tms_client.gemspec
146
126
  homepage: http://govdelivery.com
147
127
  licenses: []
148
128
  metadata: {}
@@ -152,17 +132,17 @@ require_paths:
152
132
  - lib
153
133
  required_ruby_version: !ruby/object:Gem::Requirement
154
134
  requirements:
155
- - - ">="
135
+ - - '>='
156
136
  - !ruby/object:Gem::Version
157
137
  version: '0'
158
138
  required_rubygems_version: !ruby/object:Gem::Requirement
159
139
  requirements:
160
- - - ">="
140
+ - - '>='
161
141
  - !ruby/object:Gem::Version
162
142
  version: '0'
163
143
  requirements: []
164
144
  rubyforge_project:
165
- rubygems_version: 2.2.2
145
+ rubygems_version: 2.0.14
166
146
  signing_key:
167
147
  specification_version: 4
168
148
  summary: A ruby client to interact with the GovDelivery TMS REST API.
data/bin/autospec DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'autospec' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('rspec-core', 'autospec')
data/bin/htmldiff DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'htmldiff' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('diff-lcs', 'htmldiff')
data/bin/ldiff DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'ldiff' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('diff-lcs', 'ldiff')
data/bin/rake DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rake' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('rake', 'rake')
data/bin/redcarpet DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'redcarpet' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('redcarpet', 'redcarpet')
data/bin/rspec DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rspec' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('rspec-core', 'rspec')
data/bin/tt DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'tt' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('treetop', 'tt')
data/bin/yard DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'yard' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('yard', 'yard')
data/bin/yardoc DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'yardoc' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('yard', 'yardoc')
data/bin/yri DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'yri' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('yard', 'yri')