tms_client 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -22,7 +22,7 @@ Connecting
22
22
  Loading an instance of `TMS::Client` will automatically connect to the API to query the available resources for your account.
23
23
 
24
24
  ```ruby
25
- client = TMS::Client.new('username', 'password', :api_root => 'https://stage-tms.govdelivery.com')
25
+ client = TMS::Client.new('auth_token', :api_root => 'https://stage-tms.govdelivery.com')
26
26
  ```
27
27
 
28
28
  Messages
@@ -173,7 +173,7 @@ The example below configures `TMS::Client` to log to `STDOUT`:
173
173
 
174
174
  ```ruby
175
175
  logger = Logger.new(STDOUT)
176
- client = TMS::Client.new('username', 'password', :logger => logger)
176
+ client = TMS::Client.new('auth_token', :logger => logger)
177
177
  ```
178
178
 
179
179
  ActionMailer integration
@@ -190,8 +190,7 @@ config/environment.rb
190
190
  ```ruby
191
191
  config.action_mailer.delivery_method = :govdelivery_tms
192
192
  config.action_mailer.govdelivery_tms_settings = {
193
- :username=>'email@foo.com',
194
- :password=>'pass',
193
+ :auth_token=>'auth_token',
195
194
  :api_root=>'https://stage-tms.govdelivery.com'
196
195
  }
197
196
  ```
@@ -9,25 +9,24 @@ class TMS::Client
9
9
 
10
10
  # Create a new client and issue a request for the available resources for a given account.
11
11
  #
12
- # @param [String] username The username of your account
13
- # @param [String] password The password of your account
12
+ # @param [String] auth_token The auth_token of your account
14
13
  # @param [Hash] options
15
14
  # @option options [String] :api_root The root URL of the TMS api. Defaults to localhost:3000
16
15
  # @option options [Logger] :logger An instance of a Logger class (http transport information will be logged here) - defaults to nil
17
16
  #
18
17
  # @example
19
- # client = TMS::Client.new("foo@example.com", "onetwothree", {
18
+ # client = TMS::Client.new("auth_token", {
20
19
  # :api_root => "https://tms.govdelivery.com",
21
20
  # :logger => Logger.new(STDOUT)})
22
21
  #
23
- def initialize(username, password, options = DEFAULTS)
22
+ def initialize(auth_token, options = DEFAULTS)
24
23
  @api_root = options[:api_root]
25
- connect!(username, password, options[:logger])
24
+ connect!(auth_token, options[:logger])
26
25
  discover!
27
26
  end
28
27
 
29
- def connect!(username, password, logger)
30
- self.connection = TMS::Connection.new(:username => username, :password => password, :api_root => @api_root, :logger => logger)
28
+ def connect!(auth_token, logger)
29
+ self.connection = TMS::Connection.new(:auth_token => auth_token, :api_root => @api_root, :logger => logger)
31
30
  end
32
31
 
33
32
  def discover!
@@ -1,5 +1,5 @@
1
1
  class TMS::Connection
2
- attr_accessor :username, :password, :api_root, :connection, :logger
2
+ attr_accessor :auth_token, :api_root, :connection, :logger
3
3
 
4
4
  def get(href)
5
5
  resp = connection.get("#{href}.json")
@@ -11,10 +11,9 @@ class TMS::Connection
11
11
  end
12
12
 
13
13
  def initialize(opts={})
14
- self.username = opts[:username]
15
- self.password = opts[:password]
16
- self.api_root = opts[:api_root]
17
- self.logger = opts[:logger]
14
+ self.auth_token = opts[:auth_token]
15
+ self.api_root = opts[:api_root]
16
+ self.logger = opts[:logger]
18
17
  setup_connection
19
18
  end
20
19
 
@@ -22,7 +21,8 @@ class TMS::Connection
22
21
  self.connection = Faraday.new(:url => self.api_root) do |faraday|
23
22
  faraday.use TMS::Logger, self.logger if self.logger
24
23
  faraday.request :json
25
- faraday.basic_auth(self.username, self.password)
24
+ faraday.headers['X-AUTH-TOKEN'] = auth_token
25
+ faraday.headers[:user_agent] = "GovDelivery Ruby TMS::Client #{TMS::VERSION}"
26
26
  faraday.response :json, :content_type => /\bjson$/
27
27
  faraday.adapter :net_http
28
28
  end
@@ -11,8 +11,7 @@ module TMS
11
11
  # # config/environment.rb
12
12
  # config.action_mailer.delivery_method = :govdelivery_tms
13
13
  # config.action_mailer.govdelivery_tms_settings = {
14
- # :username=>'email@foo.com',
15
- # :password=>'pass',
14
+ # :auth_token=>'auth_token',
16
15
  # :api_root=>'https://stage-tms.govdelivery.com'
17
16
  # }
18
17
  class DeliveryMethod
@@ -42,7 +41,7 @@ module TMS
42
41
  end
43
42
 
44
43
  def client
45
- @client ||= TMS::Client.new(settings[:username], settings[:password], settings)
44
+ @client ||= TMS::Client.new(settings[:auth_token], settings)
46
45
  end
47
46
  end
48
47
  end
@@ -50,8 +49,7 @@ end
50
49
 
51
50
  if defined?(ActionMailer)
52
51
  ActionMailer::Base.add_delivery_method :govdelivery_tms, TMS::Mail::DeliveryMethod, {
53
- :username => nil,
54
- :password => nil,
52
+ :auth_token => nil,
55
53
  :logger => ActionMailer::Base.logger,
56
54
  :api_root => TMS::Client::DEFAULTS[:api_root]}
57
55
  end
@@ -1,3 +1,3 @@
1
1
  module TMS #:nodoc:
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -5,7 +5,7 @@ describe TMS::Client do
5
5
  response = double('response', :status=>200, :body => {"_links" => [{"self" => "/"}, {"horse" => "/horses/new"}, {"rabbits" => "/rabbits"}]})
6
6
  @raw_connection = double('raw_connection', :get => response)
7
7
  @connection = TMS::Connection.stub(:new).and_return(double('connection', :connection => @raw_connection))
8
- @client = TMS::Client.new('username', 'password', :api_root => 'null_url')
8
+ @client = TMS::Client.new('auth_token', :api_root => 'null_url')
9
9
  end
10
10
  it 'should discover endpoints for known services' do
11
11
  @client.horse.should be_kind_of(TMS::Horse)
metadata CHANGED
@@ -1,58 +1,65 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tms_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - GovDelivery
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-06-01 00:00:00.000000000 Z
12
+ date: 2013-06-14 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: faraday
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: faraday_middleware
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: activesupport
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
- description: 'A reference implementation, written in Ruby, to interact with GovDelivery''s
62
+ description: ! 'A reference implementation, written in Ruby, to interact with GovDelivery''s
56
63
  TMS API. The client is compatible with Ruby versions 1.8.7 and 1.9.3. '
57
64
  email:
58
65
  - support@govdelivery.com
@@ -104,26 +111,33 @@ files:
104
111
  - spec/tms_client_spec.rb
105
112
  homepage: http://govdelivery.com
106
113
  licenses: []
107
- metadata: {}
108
114
  post_install_message:
109
115
  rdoc_options: []
110
116
  require_paths:
111
117
  - lib
112
118
  required_ruby_version: !ruby/object:Gem::Requirement
119
+ none: false
113
120
  requirements:
114
- - - '>='
121
+ - - ! '>='
115
122
  - !ruby/object:Gem::Version
116
123
  version: '0'
124
+ segments:
125
+ - 0
126
+ hash: -2902560472954263906
117
127
  required_rubygems_version: !ruby/object:Gem::Requirement
128
+ none: false
118
129
  requirements:
119
- - - '>='
130
+ - - ! '>='
120
131
  - !ruby/object:Gem::Version
121
132
  version: '0'
133
+ segments:
134
+ - 0
135
+ hash: -2902560472954263906
122
136
  requirements: []
123
137
  rubyforge_project:
124
- rubygems_version: 2.0.3
138
+ rubygems_version: 1.8.25
125
139
  signing_key:
126
- specification_version: 4
140
+ specification_version: 3
127
141
  summary: A ruby client to interact with the GovDelivery TMS REST API.
128
142
  test_files:
129
143
  - spec/client_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: b7a0be5e64161ecf0605c965d2bb949ec4b157db
4
- data.tar.gz: 6f725c6cb7c2f771dd7cbc07d67f00ad113af1fb
5
- SHA512:
6
- metadata.gz: 8ede49f2709329392caa5e954071b769f136abe14f6ad32f7f1f8ca617314fe0f07a4025c6e1dc2d6cd7bd4298bc0d8d961381d366e46671d38da898a2b16197
7
- data.tar.gz: 4bc8ad9a68092470eea57fd069d6cc6fba3c1b0491f0c28489be27141a3ec25f8f760078e2e53ec76ced4edb35cf4062d72cd03068a323ade5f46b50f9303abb