allorails 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +0 -1
- data/README.md +66 -4
- data/Rakefile +1 -1
- data/allorails.gemspec +2 -2
- data/lib/allorails/request/request.rb +9 -1
- data/lib/allorails/response/response.rb +4 -4
- data/test/allorails_spec.rb +6 -1
- metadata +2 -2
data/Manifest
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,69 @@
|
|
1
|
-
|
1
|
+
# Allorails
|
2
2
|
|
3
|
-
|
3
|
+
Allorails is a Ruby client for Allopass's online payment REST API. It allows Ruby and Rails developers to easily integrate their software with the Allopass online payment platform.
|
4
4
|
|
5
|
-
|
5
|
+
### Setup
|
6
6
|
|
7
|
-
|
7
|
+
Despite the name, Allorails *does not* require Rails, and can be used just like any ordinary Ruby gem:
|
8
|
+
|
9
|
+
gem install allorails
|
10
|
+
|
11
|
+
will install the `allorails` gem on your system. You can then `require "allorails"` from your Ruby code, which makes the `Allorails` class available.
|
12
|
+
|
13
|
+
**Rails users**, you can simply add the following line to your `Gemfile`
|
14
|
+
|
15
|
+
gem allorails
|
16
|
+
|
17
|
+
### Configuration
|
18
|
+
|
19
|
+
You can provide configuration options to Allorails by calling `Allorails.config` :
|
20
|
+
|
21
|
+
Allorails.config({
|
22
|
+
:accounts => {
|
23
|
+
:'your@account.email' => {
|
24
|
+
:api_key => 'your-allopass-api-key',
|
25
|
+
:private_key => 'your-allopass-private-key'
|
26
|
+
}
|
27
|
+
}
|
28
|
+
})
|
29
|
+
|
30
|
+
**Rails users**: you can put the above code in an initializer, e.g. `config/initializers/allorails.rb`, or use the `allorails.yml` configuration method explained below.
|
31
|
+
|
32
|
+
**Multiple accounts** can be set up by adding other email addresses to the `:accounts` hash.
|
33
|
+
|
34
|
+
### Usage
|
35
|
+
|
36
|
+
Now that the configuration is done, let's start using the API:
|
37
|
+
|
38
|
+
api = Allorails::Api.new
|
39
|
+
response = api.get_onetime_pricing({'site_id' => YOUR_SITE_ID, 'country' => 'UK'})
|
40
|
+
puts response.creation_date
|
41
|
+
|
42
|
+
If you have set up multiple accounts, you can choose which one to use by passing the email address to Api.new: `Allorails::Api.new('your@account.email')`
|
43
|
+
|
44
|
+
### Rails users: `allorails.yml` configuration file
|
45
|
+
|
46
|
+
You can put your configuration options in a yaml file located at `config/allorails.yml`. This file must have the same structure as the standard `database.yml` file found in all Rails applications, i.e. it must include a key for each environment:
|
47
|
+
|
48
|
+
development:
|
49
|
+
accounts:
|
50
|
+
your@account.email:
|
51
|
+
api_key: "YOUR_API_KEY"
|
52
|
+
private_key: "YOUR_PRIVATE_KEY"
|
53
|
+
|
54
|
+
# optional settings
|
55
|
+
# (the values below are the defaults)
|
56
|
+
default_hash: "sha1"
|
57
|
+
default_format: "json"
|
58
|
+
network_timeout: 20
|
59
|
+
network_protocol: "http"
|
60
|
+
network_port: 80
|
61
|
+
host: "api.allopass.com"
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
### Credits
|
68
|
+
|
69
|
+
Allorails is inspired by the Allopass ApiKit for Python written by Pierre Geoffroy and available [here](http://developer.allopass.com/apidoc/kit/python3.1/index.html).
|
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.
|
5
|
+
Echoe.new('allorails', '0.3.2') 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,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "allorails"
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.2"
|
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"]
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
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", "
|
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"]
|
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"]
|
@@ -38,7 +38,7 @@ module Allorails
|
|
38
38
|
# @param emailAccount (string) Configurated email account
|
39
39
|
def initialize(parameters, mapping = true, email_account = nil)
|
40
40
|
@_mapping = mapping
|
41
|
-
@_parameters = parameters
|
41
|
+
@_parameters = _stringify_symbols parameters
|
42
42
|
@_email_account = email_account
|
43
43
|
end
|
44
44
|
|
@@ -55,6 +55,14 @@ module Allorails
|
|
55
55
|
return Allorails::Response::ApiResponse.new(signature, headers, body)
|
56
56
|
end
|
57
57
|
end
|
58
|
+
|
59
|
+
# Internal method to turn symbols (keys and values) into strings
|
60
|
+
def _stringify_symbols x
|
61
|
+
return x.to_s if x.is_a?(Symbol)
|
62
|
+
return x.map{|y| _stringify_symbols y} if x.is_a?(Array)
|
63
|
+
return x.inject({}) {|h, (k,v)| h[_stringify_symbols k] = _stringify_symbols v; h} if x.is_a?(Hash)
|
64
|
+
return x
|
65
|
+
end
|
58
66
|
|
59
67
|
## Internal method building special required API parameters
|
60
68
|
#
|
@@ -123,7 +123,7 @@ module Allorails
|
|
123
123
|
|
124
124
|
## Provides the website
|
125
125
|
# @return (Website) website
|
126
|
-
node_reader :website
|
126
|
+
node_reader :website, Website
|
127
127
|
|
128
128
|
## Provides the pricepoints by countries
|
129
129
|
# @return (Array) available countries (list of Country object)
|
@@ -190,7 +190,7 @@ module Allorails
|
|
190
190
|
|
191
191
|
## Provides the website
|
192
192
|
# @return (Website) website
|
193
|
-
node_reader :website
|
193
|
+
node_reader :website, Website
|
194
194
|
|
195
195
|
## Provides the customer ip
|
196
196
|
# @return (string) customer ip
|
@@ -256,7 +256,7 @@ module Allorails
|
|
256
256
|
|
257
257
|
## Provides the website
|
258
258
|
# @return (Website) website
|
259
|
-
node_reader :website
|
259
|
+
node_reader :website, Website
|
260
260
|
|
261
261
|
## Provides the expected number of codes
|
262
262
|
# @return (int) expected number of codes
|
@@ -306,7 +306,7 @@ module Allorails
|
|
306
306
|
|
307
307
|
## Provides the website
|
308
308
|
# @return (Website) website
|
309
|
-
node_reader :website
|
309
|
+
node_reader :website, Website
|
310
310
|
|
311
311
|
## Provides the buy url
|
312
312
|
# @return (string) buy url
|
data/test/allorails_spec.rb
CHANGED
@@ -31,10 +31,11 @@ end
|
|
31
31
|
|
32
32
|
describe Allorails::Api, "#get_onetime_pricing" do
|
33
33
|
api = Allorails::Api.new
|
34
|
-
resp = api.get_onetime_pricing({'site_id' => YOUR_SITE_ID, 'country' => TEST_COUNTRY_CODE})
|
35
34
|
it "returns a valid response" do
|
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
|
resp.creation_date.is_a?(DateTime).should be_true
|
38
|
+
resp.website.is_a?(Allorails::Website).should be_true
|
38
39
|
resp.regions.is_a?(Array).should be_true
|
39
40
|
resp.regions.each do |reg|
|
40
41
|
reg.is_a?(Allorails::Region).should be_true
|
@@ -45,6 +46,10 @@ describe Allorails::Api, "#get_onetime_pricing" do
|
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
49
|
+
it "works with symbol keys and values" do
|
50
|
+
resp = api.get_onetime_pricing({:site_id => YOUR_SITE_ID, :country => TEST_COUNTRY_CODE.to_sym})
|
51
|
+
resp.creation_date.is_a?(DateTime).should be_true
|
52
|
+
end
|
48
53
|
end
|
49
54
|
|
50
55
|
describe Allorails::Api, "#create_discrete_button" do
|
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.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -28,7 +28,6 @@ extra_rdoc_files:
|
|
28
28
|
files:
|
29
29
|
- README.md
|
30
30
|
- Rakefile
|
31
|
-
- allorails.gemspec
|
32
31
|
- init.rb
|
33
32
|
- lib/allorails.rb
|
34
33
|
- lib/allorails/api/api.rb
|
@@ -42,6 +41,7 @@ files:
|
|
42
41
|
- test/test-conf-sample.yml
|
43
42
|
- test/test-conf.yml
|
44
43
|
- Manifest
|
44
|
+
- allorails.gemspec
|
45
45
|
homepage: http://github.com/davb/allorails
|
46
46
|
licenses: []
|
47
47
|
post_install_message:
|