allorails 0.3.2 → 0.4.1

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.
data/Manifest CHANGED
@@ -1,5 +1,6 @@
1
1
  README.md
2
2
  Rakefile
3
+ allorails.gemspec
3
4
  init.rb
4
5
  lib/allorails.rb
5
6
  lib/allorails/api/api.rb
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('allorails', '0.3.2') do |p|
5
+ Echoe.new('allorails', '0.4.1') do |p|
6
6
  p.description = "Ruby client for the Allopass online payment REST API"
7
7
  p.url = "http://github.com/davb/allorails"
8
8
  p.author = "Davide Bonapersona"
data/allorails.gemspec CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "allorails"
5
- s.version = "0.3.2"
5
+ s.version = "0.4.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Davide Bonapersona"]
9
- s.date = "2012-05-08"
9
+ s.date = "2012-05-10"
10
10
  s.description = "Ruby client for the Allopass online payment REST API"
11
11
  s.email = "davide@feeligo.com"
12
12
  s.extra_rdoc_files = ["README.md", "lib/allorails.rb", "lib/allorails/api/api.rb", "lib/allorails/core.rb", "lib/allorails/errors/errors.rb", "lib/allorails/rails.rb", "lib/allorails/request/request.rb", "lib/allorails/response/model.rb", "lib/allorails/response/response.rb"]
13
- s.files = ["README.md", "Rakefile", "init.rb", "lib/allorails.rb", "lib/allorails/api/api.rb", "lib/allorails/core.rb", "lib/allorails/errors/errors.rb", "lib/allorails/rails.rb", "lib/allorails/request/request.rb", "lib/allorails/response/model.rb", "lib/allorails/response/response.rb", "test/allorails_spec.rb", "test/test-conf-sample.yml", "test/test-conf.yml", "Manifest", "allorails.gemspec"]
13
+ s.files = ["README.md", "Rakefile", "allorails.gemspec", "init.rb", "lib/allorails.rb", "lib/allorails/api/api.rb", "lib/allorails/core.rb", "lib/allorails/errors/errors.rb", "lib/allorails/rails.rb", "lib/allorails/request/request.rb", "lib/allorails/response/model.rb", "lib/allorails/response/response.rb", "test/allorails_spec.rb", "test/test-conf-sample.yml", "test/test-conf.yml", "Manifest"]
14
14
  s.homepage = "http://github.com/davb/allorails"
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Allorails", "--main", "README.md"]
16
16
  s.require_paths = ["lib"]
@@ -94,9 +94,9 @@ module Allorails
94
94
  # @return ApiRequest Class instance for chaining purpose
95
95
  def _sign
96
96
  params = @_parameters.dup
97
-
97
+
98
98
  if params.has_key?('code')
99
- params['code'] = params['code'].join
99
+ params['code'] = params.delete('code').join
100
100
  end
101
101
 
102
102
  sign = params.sort.map{|p| "#{p[0]}#{p[1]}"}.join
@@ -138,7 +138,7 @@ module Allorails
138
138
  }
139
139
 
140
140
  # use a proxy?
141
- use_proxy = false
141
+ use_proxy = true
142
142
  http_class = if use_proxy then Net::HTTP::Proxy('127.0.0.1', 9999) else Net::HTTP end
143
143
 
144
144
  # prepare and send HTTP request
@@ -173,8 +173,7 @@ module Allorails
173
173
  # in a slightly different matter than urlencode does
174
174
  if params.has_key?('code')
175
175
  codes = params.delete('code')
176
- hash_codes = Hash[[0..codes.length-1].map{|i| ["code[#{i}]",codes[i]]}]
177
- params = params.merge(hash_codes)
176
+ (0..codes.length-1).each{|i| params["code[#{i}]"] = codes[i]}
178
177
  end
179
178
 
180
179
  URI::encode params.collect { |k,v| "#{k}=#{v}" }.join('&') #CGI::escape(v.to_s)
@@ -84,7 +84,7 @@ module Allorails
84
84
  ## Provides the pricepoints available in this market
85
85
  # @return (Array) available pricepoints (list of Pricepoint objects)
86
86
  def pricepoints
87
- json.children.values.map{|c| ::Allorails::Pricepoint.new(c)}
87
+ json.pricepoint.map{|c| ::Allorails::Pricepoint.new(c)}
88
88
  end
89
89
 
90
90
  end
@@ -99,7 +99,7 @@ module Allorails
99
99
 
100
100
  ## Provides the amount
101
101
  # @return (float) amount
102
- node_reader :currency, Float
102
+ node_reader :amount, Float
103
103
 
104
104
  ## Provides the day's exchange rate
105
105
  # @return (float) exchange rate
@@ -23,11 +23,6 @@ module Allorails
23
23
  def _verify
24
24
  raise Allorails::ApiFalseResponseSignatureError unless @_headers['x-allopass-response-signature'].include?(@_signature)
25
25
  end
26
-
27
- ## Custom print result
28
- def to_s
29
- @_body
30
- end
31
26
 
32
27
  end # -- end class ApiResponse
33
28
 
@@ -93,7 +88,7 @@ module Allorails
93
88
  cast = case true
94
89
  when type == String then Proc.new{|x| x.to_s}
95
90
  when type == Integer then Proc.new{|x| x.to_i}
96
- when type == Float then Proc.new{|x| to_f}
91
+ when type == Float then Proc.new{|x| x.to_f}
97
92
  when type == DateTime then Proc.new{|x| x.date.nil? ? (x.timestamp.nil? ? nil : DateTime.strptime(x.timestamp, "%s")) : DateTime.strptime(x.date)}
98
93
  else Proc.new{|x| type.new x}
99
94
  end
@@ -34,6 +34,7 @@ describe Allorails::Api, "#get_onetime_pricing" do
34
34
  it "returns a valid response" do
35
35
  resp = api.get_onetime_pricing({'site_id' => YOUR_SITE_ID, 'country' => TEST_COUNTRY_CODE})
36
36
  resp.to_s.should_not be_nil
37
+
37
38
  resp.creation_date.is_a?(DateTime).should be_true
38
39
  resp.website.is_a?(Allorails::Website).should be_true
39
40
  resp.regions.is_a?(Array).should be_true
@@ -45,6 +46,28 @@ describe Allorails::Api, "#get_onetime_pricing" do
45
46
  (ctry.code.length > 0).should be_true
46
47
  end
47
48
  end
49
+
50
+ resp.markets.is_a?(Array).should be_true
51
+ resp.markets.each do |m|
52
+ m.is_a?(Allorails::Market).should be_true
53
+ m.country_code.is_a?(String).should be_true
54
+ m.country.is_a?(String).should be_true
55
+ m.pricepoints.is_a?(Array).should be_true
56
+ m.pricepoints.each do |pp|
57
+ pp.is_a?(Allorails::Pricepoint).should be_true
58
+ pp.price.is_a?(Allorails::Price).should be_true
59
+ pp.payout.is_a?(Allorails::Payout).should be_true
60
+
61
+ [pp.price, pp.payout].each do |ppp|
62
+ ppp.currency.is_a?(String).should be_true
63
+ ppp.amount.is_a?(Float).should be_true
64
+ ppp.exchange.is_a?(Float).should be_true
65
+ ppp.reference_currency.is_a?(String).should be_true
66
+ ppp.reference_amount.is_a?(Float).should be_true
67
+ end
68
+
69
+ end
70
+ end
48
71
  end
49
72
  it "works with symbol keys and values" do
50
73
  resp = api.get_onetime_pricing({:site_id => YOUR_SITE_ID, :country => TEST_COUNTRY_CODE.to_sym})
@@ -71,4 +94,19 @@ describe Allorails::Api, "#create_discrete_button" do
71
94
  resp.button_id.should_not be_nil
72
95
  resp.website.is_a?(Allorails::Website).should be_true
73
96
  end
97
+ end
98
+
99
+ describe Allorails::Api, "#validate_codes" do
100
+ api = Allorails::Api.new
101
+ resp = api.validate_codes(
102
+ 'site_id' => YOUR_SITE_ID,
103
+ 'code' => ['X226658Z'],
104
+ 'product_name' => 'zeproduct'
105
+ )
106
+ it "returns a valid response" do
107
+ resp.to_s.should_not be_nil
108
+ resp.is_a?(Allorails::Response::OnetimeValidateCodesResponse).should be_true
109
+ (resp.json).should_not be_nil
110
+ #puts resp.json.inspect #DEBUG
111
+ end
74
112
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allorails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-08 00:00:00.000000000 Z
12
+ date: 2012-05-10 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Ruby client for the Allopass online payment REST API
15
15
  email: davide@feeligo.com
@@ -28,6 +28,7 @@ extra_rdoc_files:
28
28
  files:
29
29
  - README.md
30
30
  - Rakefile
31
+ - allorails.gemspec
31
32
  - init.rb
32
33
  - lib/allorails.rb
33
34
  - lib/allorails/api/api.rb
@@ -41,7 +42,6 @@ files:
41
42
  - test/test-conf-sample.yml
42
43
  - test/test-conf.yml
43
44
  - Manifest
44
- - allorails.gemspec
45
45
  homepage: http://github.com/davb/allorails
46
46
  licenses: []
47
47
  post_install_message: