soaspec 0.0.73 → 0.0.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 560cab022af5b3297cf79ae3bfd3b71cb023ac3d
4
- data.tar.gz: c178b241de61f0ff91001ab1c710dd196ec6e611
3
+ metadata.gz: 43fd4464188493e9968c067148b269757e361b12
4
+ data.tar.gz: 94f6d5ea2560811e1069dcdb257f0823c777b301
5
5
  SHA512:
6
- metadata.gz: 4aad8d63361904d563c10534248dc90376d493712e579e6da2d1e8a787940664e51261531bcd2d37e038c28bfe19e300665f9df3a65b7c5841a968246ec9fcd7
7
- data.tar.gz: 0e93c0c83266d50026b4c36488b63abbe26a31987006fa2f964487b9c94d3c74517c26c228ba0a927c3840716e4f2b9ace495ac6bb8d8bd3e7e3d36a6495c16b
6
+ metadata.gz: 32d11b91846fb9d336076babc1dec2c9a398d04b234f90fed6dfdb9cb99f80fd6ada68884a057d090cbe83be447e579eb59c7a18b8900f8dc7f435a48b29f870
7
+ data.tar.gz: 795b62a2d2eaf78cbf6d58271389bdfca3f682411669c877f3088ffa0b61b954a233986a086bbea3d7513c8c85b3f01ff9991b1a5f8882b1d5eb458e6638a9e1
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Version 0.0.74
2
+ * Enhancements
3
+ * RestHandler, enable api username to be set upon initialisation
4
+
1
5
  Version 0.0.73
2
6
  * Enhancements
3
7
  * Added 'default_handler' method with which define an exchange_handler to be created when an exchange is initialized
@@ -32,11 +32,12 @@ class SoaspecVirtualServer < Sinatra::Application
32
32
 
33
33
  # Simulate retrieving an ouath token. Passed to '/invoices'
34
34
  post '/as/token.oauth2' do
35
- [200, Soaspec::TestServer::Invoices.oauth_headers, JSON.generate(Soaspec::TestServer::Invoices.oauth_body) ] #Soaspec::TestServer::Invoices.oauth_headers, ]# JSON.generate(Soaspec::TestServer::Invoices.oauth_body)]
35
+ Soaspec::TestServer::Invoices.user_used = request.env['rack.request.form_hash']['username']
36
+ [200, Soaspec::TestServer::Invoices.oauth_headers, JSON.generate(Soaspec::TestServer::Invoices.oauth_body)]
36
37
  end
37
38
 
38
39
  get '/invoice/:id' do |id|
39
- JSON.generate(customer_id: id, oauth: request.env['HTTP_AUTHORIZATION'])
40
+ JSON.generate(customer_id: id, oauth: request.env['HTTP_AUTHORIZATION'], user: Soaspec::TestServer::Invoices.user_used)
40
41
  end
41
42
 
42
43
  authorize do |username, password|
@@ -5,9 +5,12 @@ module ExchangeAccessors
5
5
 
6
6
  # Set default exchange handler for this exchange
7
7
  # This is helpful for when you need a new exchange handler created for each exchange
8
- def default_handler(handler_class, name = handler_class.to_s, params = {})
8
+ def default_handler(handler_class, name = handler_class.to_s, params = '')
9
9
  define_method('default_handler_used') do
10
- handler_class.new name, params
10
+ params_used = Hash[params.map do |k, param|
11
+ [k, param.is_a?(String) ? ERB.new(param).result(binding) : param]
12
+ end]
13
+ handler_class.new name, params_used
11
14
  end
12
15
  end
13
16
  end
@@ -19,7 +22,7 @@ class Exchange
19
22
 
20
23
  extend ExchangeAccessors
21
24
 
22
- # Class of Exchange Handler for which this exchange is made
25
+ # Instance of ExchangeHandler for which this exchange is made
23
26
  attr_accessor :exchange_handler
24
27
  # How many times to retry for a success
25
28
  attr_accessor :retry_count
@@ -100,10 +100,6 @@ module Soaspec
100
100
  class RestHandler < ExchangeHandler
101
101
  extend Soaspec::RestAccessors
102
102
 
103
- # Savon client used to make SOAP calls
104
- attr_accessor :client
105
- # SOAP Operation to use by default
106
- attr_accessor :operation
107
103
  # User used in making API calls
108
104
  attr_accessor :api_username
109
105
 
@@ -142,6 +138,7 @@ module Soaspec
142
138
  name = self.class.to_s
143
139
  end
144
140
  super
141
+ set_remove_key(options, :api_username)
145
142
  set_remove_key(options, :default_hash)
146
143
  @init_options = options
147
144
  end
@@ -2,7 +2,11 @@ module Soaspec
2
2
  module TestServer
3
3
  # Used to simulate requests requiring oauth authentication
4
4
  class Invoices
5
+ @user_used = nil
6
+
5
7
  class << self
8
+ attr_accessor :user_used
9
+
6
10
  def oauth_headers
7
11
  {
8
12
  'Content-Type' => 'application/json;charset=UTF-8'
@@ -1,3 +1,3 @@
1
1
  module Soaspec
2
- VERSION = '0.0.73'.freeze
2
+ VERSION = '0.0.74'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soaspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.73
4
+ version: 0.0.74
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamuelGarrattIQA