paytrail-client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +3 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +29 -0
- data/Rakefile +6 -0
- data/lib/paytrail-client.rb +1 -0
- data/lib/paytrail_client/helpers.rb +20 -0
- data/lib/paytrail_client/payment.rb +7 -0
- data/lib/paytrail_client/paytrail_client.rb +8 -0
- data/lib/paytrail_client/request.rb +42 -0
- data/lib/paytrail_client/version.rb +3 -0
- data/lib/paytrail_client.rb +7 -0
- data/paytrail-client.gemspec +30 -0
- metadata +171 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ad5c0678e7dd0683a726354c82b1e2f5f8b8bc8b
|
4
|
+
data.tar.gz: 68fab39c6af2dea6b9a6595f785b364649e2f996
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 18bf159b219a3a0fbc8097f3f246570a5a6177f9d742397fb22c114acbf7b03791562049a50cfd082916ecd4d09048ef1393e823249fd7794fc426602c18cc6f
|
7
|
+
data.tar.gz: 97e91cff52ba11170e8efc62a6cf652a6ad42b30fba357147862f4574287d5407218db17dce8fa8445aeec898dad4f8de28abefe75b6b3e3ba10cf00c3a67b55
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Joakim Antman
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# paytrail-client
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/anakinj/paytrail-client.svg?branch=master)](https://travis-ci.org/anakinj/paytrail-client)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'paytrail-client'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install paytrail-client
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/antmanj/paytrail-client.
|
26
|
+
|
27
|
+
## License
|
28
|
+
|
29
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'paytrail_client'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module PaytrailClient::Helpers
|
2
|
+
def self.convert_hash_keys(value)
|
3
|
+
case value
|
4
|
+
when Array
|
5
|
+
value.map(&method(:convert_hash_keys))
|
6
|
+
when Hash
|
7
|
+
Hash[value.map { |k, v| [convert_key(k), convert_hash_keys(v)] }]
|
8
|
+
else
|
9
|
+
value
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.convert_key(key)
|
14
|
+
k = key.to_s
|
15
|
+
k.chars.each_with_index do |char, i|
|
16
|
+
k[i + 1] = k[i + 1].upcase if char == '_'
|
17
|
+
end
|
18
|
+
k.delete('_')
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
module PaytrailClient::Request
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(ClassMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def post(url, body)
|
9
|
+
call(:post, url, body)
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(method, url, body)
|
13
|
+
RestClient::Request.execute(
|
14
|
+
method: method,
|
15
|
+
url: url,
|
16
|
+
payload: prepare_body(body).to_json,
|
17
|
+
timeout: PaytrailClient.configuration.request_timeout,
|
18
|
+
headers: prepare_headers,
|
19
|
+
user: PaytrailClient.configuration.merchant_id,
|
20
|
+
password: PaytrailClient.configuration.merchant_secret
|
21
|
+
) do |response, _request, _result, &_block|
|
22
|
+
parse_body(response.body)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def prepare_body(body)
|
27
|
+
PaytrailClient::Helpers.convert_hash_keys(body)
|
28
|
+
end
|
29
|
+
|
30
|
+
def prepare_headers
|
31
|
+
{
|
32
|
+
'Content-Type' => 'application/json',
|
33
|
+
'Accept' => 'application/json',
|
34
|
+
'X-Verkkomaksut-Api-Version' => '1'
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def parse_body(body)
|
39
|
+
JSON.parse(body)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'paytrail_client/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'paytrail-client'
|
8
|
+
spec.version = PaytrailClient::VERSION
|
9
|
+
spec.authors = ['Joakim Antman']
|
10
|
+
spec.email = ['antmanj@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Simple paytrail client'
|
13
|
+
spec.description = 'Client for querying the Paytrail REST API'
|
14
|
+
spec.homepage = 'https://github.com/antmanj/paytrail-client'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'rest-client', '~> 1.8'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
26
|
+
spec.add_development_dependency 'webmock', '~> 1.24'
|
27
|
+
spec.add_development_dependency 'vcr', '~> 3.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
29
|
+
spec.add_development_dependency 'simplecov', '~> 0.11'
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paytrail-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joakim Antman
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.10'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.24'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.24'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.4'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.4'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.11'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.11'
|
125
|
+
description: Client for querying the Paytrail REST API
|
126
|
+
email:
|
127
|
+
- antmanj@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- ".travis.yml"
|
135
|
+
- Gemfile
|
136
|
+
- LICENSE.txt
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- lib/paytrail-client.rb
|
140
|
+
- lib/paytrail_client.rb
|
141
|
+
- lib/paytrail_client/helpers.rb
|
142
|
+
- lib/paytrail_client/payment.rb
|
143
|
+
- lib/paytrail_client/paytrail_client.rb
|
144
|
+
- lib/paytrail_client/request.rb
|
145
|
+
- lib/paytrail_client/version.rb
|
146
|
+
- paytrail-client.gemspec
|
147
|
+
homepage: https://github.com/antmanj/paytrail-client
|
148
|
+
licenses:
|
149
|
+
- MIT
|
150
|
+
metadata: {}
|
151
|
+
post_install_message:
|
152
|
+
rdoc_options: []
|
153
|
+
require_paths:
|
154
|
+
- lib
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
requirements: []
|
166
|
+
rubyforge_project:
|
167
|
+
rubygems_version: 2.4.6
|
168
|
+
signing_key:
|
169
|
+
specification_version: 4
|
170
|
+
summary: Simple paytrail client
|
171
|
+
test_files: []
|