portatext 1.1.2 → 1.1.3

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: 8060e94cc7da5a6ec5f4b61a2019438b551f8c65
4
- data.tar.gz: c4648838ececee96cb984c2e4524636d604c2e11
3
+ metadata.gz: 300d82ceef76dd2152b3ca2089efb0ec3b4a29db
4
+ data.tar.gz: 77df65fc04157d1b0e5836c1cd6b9161cdc0cbef
5
5
  SHA512:
6
- metadata.gz: 97e8c5e54143cf3a406afccd617bf7f7972856c644fda997fd8902cf58bd1670c42afc34e1e5c919b176e7544748fc029f2cf3383956214b9b1342ff08feb296
7
- data.tar.gz: 71b5d73f5d6b56cf16e1004503c751255c125550a5127f6b692df83a31f4fcf0faa0f1feab6169c1493b6dffb6bfc9cef1a5c0e5a4e249182bb01bd7ec33a03b
6
+ metadata.gz: 07d179a439857c0dda4c6af8f9316f340b2a8da835e8e629a9173dc8622b76450dce2779f82137e40a2019e173e94ec4afa8a51e41bb5cdac3ef191f0ba88402
7
+ data.tar.gz: 1889f0b178f9bd7808060061fc7b022d6b2b2d6dea0db9f763bebd79d6ed21764b0f6d39bbfddab9952cba97d00c1f4190cd5e45b568faf07a9182cddb3e76d2
data/lib/portatext.rb CHANGED
@@ -2,6 +2,7 @@ require_relative 'portatext/exception/request_error'
2
2
  require_relative 'portatext/exception/server_error'
3
3
  require_relative 'portatext/exception/rate_limited'
4
4
  require_relative 'portatext/exception/invalid_media'
5
+ require_relative 'portatext/exception/not_acceptable'
5
6
  require_relative 'portatext/exception/invalid_method'
6
7
  require_relative 'portatext/exception/not_found'
7
8
  require_relative 'portatext/exception/forbidden'
@@ -33,6 +34,7 @@ require_relative 'portatext/command/api/campaigns'
33
34
  require_relative 'portatext/command/api/sms_campaign'
34
35
  require_relative 'portatext/command/api/campaign_lifecycle'
35
36
  require_relative 'portatext/command/api/my_password'
37
+ require_relative 'portatext/command/api/variables'
36
38
 
37
39
  # The PortaText namespace.
38
40
  #
@@ -8,6 +8,7 @@ module PortaText
8
8
  # Author:: Marcelo Gornstein (mailto:marcelog@portatext.com)
9
9
  # Copyright:: Copyright (c) 2015 PortaText
10
10
  # License:: Apache-2.0
11
+ # rubocop:disable Metrics/ClassLength
11
12
  class BaseClient
12
13
  attr_writer :endpoint
13
14
  attr_writer :api_key
@@ -100,6 +101,7 @@ module PortaText
100
101
  403 => PortaText::Exception::Forbidden,
101
102
  404 => PortaText::Exception::NotFound,
102
103
  405 => PortaText::Exception::InvalidMethod,
104
+ 406 => PortaText::Exception::NotAcceptable,
103
105
  415 => PortaText::Exception::InvalidMedia,
104
106
  429 => PortaText::Exception::RateLimited,
105
107
  500 => PortaText::Exception::ServerError
@@ -0,0 +1,44 @@
1
+ module PortaText
2
+ module Command
3
+ module Api
4
+ # The variables endpoint.
5
+ # https://github.com/PortaText/docs/wiki/REST-API#api_variables
6
+ #
7
+ # Author:: Marcelo Gornstein (mailto:marcelog@portatext.com)
8
+ # Copyright:: Copyright (c) 2015 PortaText
9
+ # License:: Apache-2.0
10
+ class Variables < Base
11
+ def for_contact(number)
12
+ set :number, number
13
+ end
14
+
15
+ def name(name)
16
+ set :name, name
17
+ end
18
+
19
+ def set_to(name, value)
20
+ self.name name
21
+ set :value, value
22
+ end
23
+
24
+ # rubocop:disable Style/AccessorMethodName
25
+ def set_all(variables)
26
+ variables = variables.reduce([]) do |acc, v|
27
+ acc << { key: v[0], value: v[1] }
28
+ end
29
+ set :variables, variables
30
+ end
31
+ # rubocop:enable Style/AccessorMethodName
32
+
33
+ def endpoint(_method)
34
+ number = @args[:number]
35
+ @args.delete :number
36
+ return "contact/#{number}/variables" if @args[:name].nil?
37
+ name = @args[:name]
38
+ @args.delete :name
39
+ "contact/#{number}/variables/#{name}"
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,11 @@
1
+ module PortaText
2
+ module Exception
3
+ # Raised on invalid accept content type HTTP 406.
4
+ #
5
+ # Author:: Marcelo Gornstein (mailto:marcelog@portatext.com)
6
+ # Copyright:: Copyright (c) 2015 PortaText
7
+ # License:: Apache-2.0
8
+ class NotAcceptable < RequestError
9
+ end
10
+ end
11
+ end
data/portatext.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'portatext'
3
- s.version = '1.1.2'
3
+ s.version = '1.1.3'
4
4
  s.summary = 'Official PortaText API ruby client'
5
5
  s.description = 'This is the official PortaText API ruby client'
6
6
  s.authors = ['PortaText']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: portatext
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - PortaText
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-08 00:00:00.000000000 Z
11
+ date: 2016-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov
@@ -159,6 +159,7 @@ files:
159
159
  - lib/portatext/command/api/tariffs.rb
160
160
  - lib/portatext/command/api/templates.rb
161
161
  - lib/portatext/command/api/timezones.rb
162
+ - lib/portatext/command/api/variables.rb
162
163
  - lib/portatext/command/base.rb
163
164
  - lib/portatext/command/descriptor.rb
164
165
  - lib/portatext/command/result.rb
@@ -167,6 +168,7 @@ files:
167
168
  - lib/portatext/exception/invalid_credentials.rb
168
169
  - lib/portatext/exception/invalid_media.rb
169
170
  - lib/portatext/exception/invalid_method.rb
171
+ - lib/portatext/exception/not_acceptable.rb
170
172
  - lib/portatext/exception/not_found.rb
171
173
  - lib/portatext/exception/payment_required.rb
172
174
  - lib/portatext/exception/rate_limited.rb