six_saferpay 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a080926b5bdf943166bbcd992d4d7a0225312de53b76dc531bd7647ec8a42f1c
4
- data.tar.gz: dbcad29d4c52294fd934f2355176b0554c24db3696ac1e24cf64912fd6faff0b
3
+ metadata.gz: ccc4e59b09497c4bd69e43e3c83f144e0b77ed3b5fa3ab3c1a9ece66540f4b07
4
+ data.tar.gz: 5eb1be3135c3aa1eb253e8d0af0b0b5f9cda983466c5f861e3d4c01d05ad5b8a
5
5
  SHA512:
6
- metadata.gz: 3e2633d3ddd558c1efb063dea3490d37c100abb9d7fa48672d14ecab55e53fc20e24c280b1d68b5a01780d6e59c472b8ce62d7b548ae3f8b01a26d26154b9574
7
- data.tar.gz: b67ee84408caf95044891164d762bad9ad042401d982bda0d7265bcd9993934ee0e48b8345ac3b8f22a2e0e027521e48f39078997543c7274221d04274ab0469
6
+ metadata.gz: 2dc5c3e36ea120537bd0340e8d1b5228b795cadde23f6bdcfc6ab1da0ec5377f4ba85ab6f2cf877bace1e5a40511150b66c7ddb54d6fbb9ec604486ba316eb98
7
+ data.tar.gz: 20b80970bc27a450d1ecf2fb5569d11a68f0b9ae9e688c6c934d9cfa60c15379efe725d08f1555bbe43a0e76c8c275638ebeb3deaacb963e04ee091ef5481c59
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- six_saferpay (1.16.2.4.0)
4
+ six_saferpay (2.5.0)
5
5
  activesupport (~> 6.1, >= 6.1.3)
6
6
 
7
7
  GEM
@@ -22,6 +22,7 @@ GEM
22
22
  diff-lcs (1.4.4)
23
23
  docile (1.3.5)
24
24
  dotenv (2.7.6)
25
+ ffi (1.14.2-java)
25
26
  hashdiff (1.0.1)
26
27
  i18n (1.8.9)
27
28
  concurrent-ruby (~> 1.0)
@@ -32,6 +33,10 @@ GEM
32
33
  pry (0.14.0)
33
34
  coderay (~> 1.1)
34
35
  method_source (~> 1.0)
36
+ pry (0.14.0-java)
37
+ coderay (~> 1.1)
38
+ method_source (~> 1.0)
39
+ spoon (~> 0.0)
35
40
  public_suffix (4.0.6)
36
41
  rake (13.0.3)
37
42
  rexml (3.2.4)
@@ -56,6 +61,9 @@ GEM
56
61
  simplecov_json_formatter (0.1.2)
57
62
  spinning_wheel (0.2.2)
58
63
  activesupport (>= 5.2.4.3)
64
+ spoon (0.0.6)
65
+ ffi
66
+ thor (1.1.0)
59
67
  tty-color (0.6.0)
60
68
  tty-cursor (0.7.1)
61
69
  tty-prompt (0.23.0)
@@ -77,18 +85,20 @@ GEM
77
85
  zeitwerk (2.4.2)
78
86
 
79
87
  PLATFORMS
88
+ arm64-darwin-20
80
89
  java
81
90
  ruby
82
91
 
83
92
  DEPENDENCIES
84
93
  bundler (~> 2.1)
85
94
  dotenv (~> 2.7, >= 2.7)
86
- pry (~> 0.13)
95
+ pry (~> 0.14)
87
96
  rake (~> 13.0)
88
97
  rspec (~> 3.0)
89
98
  simplecov (~> 0.19)
90
99
  six_saferpay!
91
100
  spinning_wheel (~> 0.2.2)
101
+ thor (~> 1.1.0)
92
102
  tty-prompt (~> 0.22)
93
103
  vcr (~> 4.0, >= 4.0.0)
94
104
  webmock (~> 3.10, >= 3.10)
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/six_saferpay.svg)](https://badge.fury.io/rb/six_saferpay)
2
- [![Build Status](https://travis-ci.org/fadendaten/six_saferpay.svg?branch=master)](https://travis-ci.org/fadendaten/six_saferpay)
2
+ [![Build Status](https://travis-ci.com/fadendaten/six_saferpay.svg?branch=master)](https://travis-ci.com/fadendaten/six_saferpay)
3
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/76c9d1d0f261c276de96/maintainability)](https://codeclimate.com/github/fadendaten/six_saferpay/maintainability)
4
4
 
5
5
  # SixSaferpay
6
6
 
7
7
  ## Current API Version
8
8
 
9
- This gem is compatible with the SIX API version: `1.16`
9
+ This gem is compatible with the SIX API version: `1.17`
10
10
 
11
11
  ## Installation
12
12
 
data/Thorfile ADDED
@@ -0,0 +1 @@
1
+ Thor::Util.load_thorfile('lib/generators/models.rb')
@@ -0,0 +1,96 @@
1
+ require "thor"
2
+ require 'active_support/inflector'
3
+
4
+ module SixSaferpay
5
+ module Generators
6
+ class Model < Thor::Group
7
+ include Thor::Actions
8
+
9
+ attr_accessor :attributes, :file_name
10
+
11
+ argument :name
12
+ argument :method_attributes, optional: true, type: :hash
13
+ class_option :test_framework, :default => :test_unit
14
+
15
+ def self.source_root
16
+ File.dirname(__FILE__)
17
+ end
18
+
19
+ def file_name
20
+ @file_name = name.underscore
21
+ end
22
+
23
+ def create_attributes_array
24
+ @attributes = []
25
+ if method_attributes
26
+ method_attributes.each do |key, value|
27
+ split = value.split(':')
28
+
29
+ name = key.underscore
30
+ type = split.first
31
+ if split.length == 2
32
+ mandatory = split.last
33
+ else
34
+ mandatory = false
35
+ end
36
+
37
+ attribute = Attribute.new(name, type, mandatory)
38
+
39
+ @attributes << attribute
40
+ end
41
+ end
42
+ end
43
+
44
+ def create_model_file
45
+ template('templates/model.erb', "lib/six_saferpay/models/#{@file_name}.rb")
46
+ end
47
+
48
+ def create_test_file
49
+ template('templates/spec.erb', "spec/six_saferpay/models/#{@file_name}_spec.rb")
50
+ end
51
+
52
+ def create_fabric_file
53
+ template('templates/fabric.erb', "spec/fabrics/six_saferpay/models/#{@file_name.pluralize}.rb")
54
+ end
55
+
56
+ end
57
+
58
+ class Attribute
59
+ attr_accessor :name, :type, :mandatory
60
+
61
+ def initialize(name, type, mandatory = false)
62
+ @name = name
63
+ @type = type
64
+ if mandatory == "true"
65
+ @mandatory = true
66
+ elsif mandatory == "false"
67
+ @mandatory = false
68
+ else
69
+ @mandatory = mandatory
70
+ end
71
+ end
72
+
73
+ def mandatory?
74
+ @mandatory
75
+ end
76
+
77
+ def string?
78
+ @type == "String"
79
+ end
80
+
81
+ def to_s
82
+ to_h
83
+ end
84
+
85
+ def to_h
86
+ hash = Hash.new
87
+ hash.merge!(name: name)
88
+ hash.merge!(type: type)
89
+ hash.merge!(mandatory: mandatory)
90
+ hash
91
+ end
92
+
93
+ end
94
+
95
+ end
96
+ end
@@ -0,0 +1,15 @@
1
+ SpinningWheel.define do
2
+ fabric name: '<%= file_name %>', class_name: 'SixSaferpay::<%= name %>' do
3
+ <%- attributes.each do |attr| -%>
4
+ <%- if attr.string? -%>
5
+ <%- if attr.mandatory? -%>
6
+ <%= "#{attr.name} { ' ' }" %>
7
+ <%- else -%>
8
+ <%= "#{attr.name} { nil }" %>
9
+ <%- end -%>
10
+ <%- else -%>
11
+ <%= "#{attr.name} { SpinningWheel.create('#{attr.name}') }" %>
12
+ <%- end -%>
13
+ <%- end -%>
14
+ end
15
+ end
@@ -0,0 +1,56 @@
1
+ module SixSaferpay
2
+ class <%= name %>
3
+
4
+ attr_accessor(
5
+ <%- attributes.each do |attr| -%>
6
+ :<%= attr.name %>,
7
+ <%- end -%>
8
+ )
9
+
10
+ def initialize(
11
+ <%- attributes.each_with_index do |attr, index| -%>
12
+ <%= "#{attr.name}:"-%>
13
+ <%- unless attr.mandatory? -%>
14
+ <%- -%><%= ' nil' -%>
15
+ <%- end -%>
16
+ <%- unless attr == attributes.last -%>
17
+ <%- -%><%= ',' %>
18
+ <%- end -%>
19
+ <%- end %>
20
+ )
21
+ <%- attributes.each_with_index do |attr, index| -%>
22
+ <%- if attr.string? -%>
23
+ <%= "@#{attr.name} = "-%><%= "#{attr.name}" %>
24
+ <%- else -%>
25
+ <%- %>
26
+ <%= "if #{attr.name}" %>
27
+ <%= "@#{attr.name} = "-%>
28
+ <%- -%><%= "SixSaferpay::#{attr.type}.new(#{attr.name}.to_h)" %>
29
+ <%= "end" %>
30
+ <%- end -%>
31
+ <%- end -%>
32
+ end
33
+
34
+ def to_hash
35
+ hash = Hash.new
36
+ <%- attributes.each do |attr| -%>
37
+ <%- if attr.string? -%>
38
+ <%- if attr.mandatory? -%>
39
+ <%= "if @#{attr.name}" %>
40
+ <%= "hash.merge!(#{attr.name}: @#{attr.name})" %>
41
+ <%= "end" %>
42
+ <%- else -%>
43
+ <%= "hash.merge!(#{attr.name}: @#{attr.name})" %>
44
+ <%- end -%>
45
+ <%- else -%>
46
+ <%= "if @#{attr.name}" %>
47
+ <%= "hash.merge!(#{attr.name}: @#{attr.name}.to_h)" %>
48
+ <%= "end" %>
49
+ <%- end -%>
50
+ <%- end -%>
51
+ hash
52
+ end
53
+ alias_method :to_h, :to_hash
54
+
55
+ end
56
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe SixSaferpay::<%= name %> do
4
+
5
+ subject { SpinningWheel.create('<%= file_name %>') }
6
+
7
+ let(:hash) {
8
+ {
9
+ <%- attributes.each do |attr| -%>
10
+ <%- if attr.string? -%>
11
+ <%= attr.name %>: subject.<%= attr.name %>,
12
+ <%- else -%>
13
+ <%= attr.name %>: subject.<%= attr.name %>.to_h,
14
+ <%- end -%>
15
+ <%- end -%>
16
+ }
17
+ }
18
+
19
+ describe 'to_hash' do
20
+ it 'returns the hash representation of the <%=name%>' do
21
+ expect(subject.to_hash).to eq(hash)
22
+ end
23
+ end
24
+ end
data/lib/six_saferpay.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'active_support/core_ext/hash'
2
2
  require 'active_support/core_ext/string'
3
+ require 'active_support/inflector'
3
4
  require 'securerandom'
4
5
  require 'json'
5
6
  require 'net/http'
@@ -12,6 +13,10 @@ Dir[File.join(gem_root, "lib", "six_saferpay", "**/*.rb")].sort.each do |file|
12
13
  require file
13
14
  end
14
15
 
16
+ Dir[File.join(gem_root, "lib", "generators", "**/*.thor")].sort.each do |file|
17
+ require file
18
+ end
19
+
15
20
  module SixSaferpay
16
21
 
17
22
  class Config
@@ -1,5 +1,5 @@
1
1
  module SixSaferpay
2
2
  module API
3
- VERSION = '1.16'
3
+ VERSION = '1.17'
4
4
  end
5
5
  end
@@ -10,7 +10,8 @@ module SixSaferpay
10
10
  :language_code,
11
11
  :check,
12
12
  :payment_methods,
13
- :card_form
13
+ :card_form,
14
+ :payment_means
14
15
  )
15
16
 
16
17
  def initialize(request_header: nil,
@@ -21,7 +22,8 @@ module SixSaferpay
21
22
  language_code: nil,
22
23
  check: nil,
23
24
  payment_methods: nil,
24
- card_form: nil
25
+ card_form: nil,
26
+ payment_means: nil
25
27
  )
26
28
  @request_header = request_header || SixSaferpay::RequestHeader.new()
27
29
  @register_alias = SixSaferpay::RegisterAlias.new(register_alias.to_h) if register_alias
@@ -32,6 +34,7 @@ module SixSaferpay
32
34
  @check = SixSaferpay::Check.new(check.to_h) if check
33
35
  @payment_methods = payment_methods
34
36
  @card_form = SixSaferpay::CardForm.new(card_form.to_h) if card_form
37
+ @payment_means = SixSaferpay::RequestPaymentMeans.new(payment_means.to_h) if payment_means
35
38
  end
36
39
 
37
40
  def to_hash
@@ -45,6 +48,7 @@ module SixSaferpay
45
48
  hash.merge!(check: @check.to_h) if @check
46
49
  hash.merge!(payment_methods: @payment_methods) if @payment_methods
47
50
  hash.merge!(card_form: @card_form.to_h) if @card_form
51
+ hash.merge!(payment_means: @payment_means.to_h) if @payment_means
48
52
  hash
49
53
  end
50
54
  alias_method :to_h, :to_hash
@@ -5,17 +5,21 @@ module SixSaferpay
5
5
  attr_accessor(:response_header,
6
6
  :token,
7
7
  :expiration,
8
- :redirect_url
8
+ :redirect_required,
9
+ :redirect
9
10
  )
10
11
 
11
12
  def initialize(response_header:,
12
13
  token:,
13
14
  expiration:,
14
- redirect_url: )
15
+ redirect_required:,
16
+ redirect:
17
+ )
15
18
  @response_header = SixSaferpay::ResponseHeader.new(response_header.to_h) if response_header
16
19
  @token = token
17
20
  @expiration = expiration
18
- @redirect_url = redirect_url
21
+ @redirect_required = redirect_required
22
+ @redirect = SixSaferpay::Redirect.new(redirect.to_h) if redirect
19
23
  end
20
24
 
21
25
  def to_hash
@@ -23,7 +27,8 @@ module SixSaferpay
23
27
  hash.merge!(response_header: @response_header.to_h) if @response_header
24
28
  hash.merge!(token: @token) if @token
25
29
  hash.merge!(expiration: @expiration) if @expiration
26
- hash.merge!(redirect_url: @redirect_url) if @redirect_url
30
+ hash.merge!(redirect_required: @redirect_required) if !@redirect_required.nil?
31
+ hash.merge!(redirect: @redirect.to_h) if @redirect
27
32
  hash
28
33
  end
29
34
  alias_method :to_h, :to_hash
@@ -1,15 +1,24 @@
1
1
  module SixSaferpay
2
2
  class CardForm
3
3
 
4
- attr_accessor(:holder_name)
4
+ attr_accessor(
5
+ :holder_name,
6
+ :verification_code
7
+ )
5
8
 
6
- def initialize(holder_name: nil)
9
+ def initialize(
10
+ holder_name: nil,
11
+ verification_code: nil
12
+ )
7
13
  @holder_name = holder_name
14
+ @verification_code = verification_code
15
+
8
16
  end
9
17
 
10
18
  def to_hash
11
19
  hash = Hash.new
12
20
  hash.merge!(holder_name: @holder_name) if @holder_name
21
+ hash.merge!(verification_code: @verification_code) if @verification_code
13
22
  hash
14
23
  end
15
24
  alias_method :to_h, :to_hash
@@ -1,3 +1,3 @@
1
1
  module SixSaferpay
2
- VERSION = "2.4.0"
2
+ VERSION = "2.5.0"
3
3
  end
data/six_saferpay.gemspec CHANGED
@@ -31,8 +31,9 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency 'vcr', '~> 4.0', '>= 4.0.0'
32
32
  spec.add_development_dependency 'webmock', '~> 3.10', '>= 3.10'
33
33
  spec.add_development_dependency 'dotenv', '~> 2.7', '>= 2.7'
34
- spec.add_development_dependency 'pry', '~> 0.13'
34
+ spec.add_development_dependency 'pry', '~> 0.14'
35
35
  spec.add_development_dependency 'tty-prompt', '~> 0.22'
36
36
  spec.add_development_dependency 'simplecov', '~> 0.19'
37
37
  spec.add_development_dependency 'spinning_wheel', '~> 0.2.2'
38
+ spec.add_development_dependency 'thor', '~> 1.1.0'
38
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: six_saferpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fadendaten GmbH
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-02-17 00:00:00.000000000 Z
12
+ date: 2021-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -139,14 +139,14 @@ dependencies:
139
139
  requirements:
140
140
  - - "~>"
141
141
  - !ruby/object:Gem::Version
142
- version: '0.13'
142
+ version: '0.14'
143
143
  type: :development
144
144
  prerelease: false
145
145
  version_requirements: !ruby/object:Gem::Requirement
146
146
  requirements:
147
147
  - - "~>"
148
148
  - !ruby/object:Gem::Version
149
- version: '0.13'
149
+ version: '0.14'
150
150
  - !ruby/object:Gem::Dependency
151
151
  name: tty-prompt
152
152
  requirement: !ruby/object:Gem::Requirement
@@ -189,6 +189,20 @@ dependencies:
189
189
  - - "~>"
190
190
  - !ruby/object:Gem::Version
191
191
  version: 0.2.2
192
+ - !ruby/object:Gem::Dependency
193
+ name: thor
194
+ requirement: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - "~>"
197
+ - !ruby/object:Gem::Version
198
+ version: 1.1.0
199
+ type: :development
200
+ prerelease: false
201
+ version_requirements: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - "~>"
204
+ - !ruby/object:Gem::Version
205
+ version: 1.1.0
192
206
  description: This Gem helps you consume the SIX Saferpay API. Accoring the documentation
193
207
  of API of SIX Saferpay you can define your request models and get a response object
194
208
  back.
@@ -208,8 +222,13 @@ files:
208
222
  - LICENSE.txt
209
223
  - README.md
210
224
  - Rakefile
225
+ - Thorfile
211
226
  - bin/console
212
227
  - bin/setup
228
+ - lib/generators/models.rb
229
+ - lib/generators/templates/fabric.erb
230
+ - lib/generators/templates/model.erb
231
+ - lib/generators/templates/spec.erb
213
232
  - lib/six_saferpay.rb
214
233
  - lib/six_saferpay/api.rb
215
234
  - lib/six_saferpay/api/six_batch/requests/close.rb