identity-mind 0.1.0 → 0.2.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: 01aeca0539a031175ed24deacc9290d5df921d8110c51d5d5d6fdcb0031fa10e
4
- data.tar.gz: e154bb80fd31c7f9943cdddbfb8ae26704b1c72cd25f344f2f4ea13bbfa4b7ae
3
+ metadata.gz: 36107bda05bc43b5019cb38c4d0bcdd055ad484c603cdf445ed02d9d2d04ed8c
4
+ data.tar.gz: abc2f2d06e02828941e8a2db8c60fef8369b153f01ea7b6e5f739d1094d063c1
5
5
  SHA512:
6
- metadata.gz: 838e054f2fbd0bc77375c890b30a183a86c6eb17b4fc78587a468b6105d189ab622d36db473c6f75629b2215e1949287b1a489d57b0a50d1b85f5a8583f3bee2
7
- data.tar.gz: 75420c9b73b7229fed953d15a95e1b52ca0008347888caa8c1425ce624d17f7597305a8fa6e7c1b614b4d303f023b0456cf12bae4d952f4e14b3db211cda8f11
6
+ metadata.gz: 85ba208261f31efc1d83ebd1feb51ab3a7799f7821042c2c771f94f3dc768d0d4e27bdff2976a556a717ae08a14bef424ffb97d657fa13ed44e1868fd4436f08
7
+ data.tar.gz: 70eb05a4f23f43af056fa36168d4117ba17219c06b302b641b6dca739d9aaecb3259ec6c5c0ebbccd5e8b8b347733f345aa031da5c8e096ba585fd036acc6998
@@ -0,0 +1,6 @@
1
+ # 0.2.0
2
+ - Introduce Params class with trimmed values
3
+
4
+ # 0.1.0
5
+ - Possibility to call Identity Mind API
6
+ - Created posibility to create and fetch merchant
@@ -1,6 +1,7 @@
1
1
  require 'ostruct'
2
2
  require 'httparty'
3
3
  require 'identity_mind/version'
4
+ require 'identity_mind/params'
4
5
  require 'identity_mind/response_error'
5
6
  require 'identity_mind/entity'
6
7
  require 'identity_mind/account'
@@ -27,6 +28,14 @@ module IdentityMind
27
28
  true
28
29
  end
29
30
 
31
+ def load_default_configuration
32
+ @configuration = nil
33
+ configure do |config|
34
+ config.base_uri = 'https://edna.identitymind.com'
35
+ config.param_length_limit = 128
36
+ end
37
+ end
38
+
30
39
  def perform_request(http_method, path, options, &block)
31
40
  result = super
32
41
  return result if result.success?
@@ -35,7 +44,5 @@ module IdentityMind
35
44
  end
36
45
  end
37
46
 
38
- configure do |config|
39
- config.base_uri = 'https://edna.identitymind.com'
40
- end
47
+ load_default_configuration
41
48
  end
@@ -10,7 +10,7 @@ module IdentityMind
10
10
  end
11
11
 
12
12
  def create(params)
13
- new(IdentityMind.post(path, body: params.to_json).body)
13
+ new(IdentityMind.post(path, body: Params[params].to_json).body)
14
14
  end
15
15
 
16
16
  def fetch(transaction_id)
@@ -0,0 +1,55 @@
1
+ module IdentityMind
2
+ class Params < OpenStruct
3
+ def self.[](hash)
4
+ return hash if hash.is_a?(self)
5
+
6
+ new(hash)
7
+ end
8
+
9
+ def initialize(hash = nil)
10
+ @table = {}
11
+ return unless hash
12
+
13
+ hash.each_pair do |k, v|
14
+ @table[k.to_sym] = parse_param(v)
15
+ end
16
+ end
17
+
18
+ def []=(name, value)
19
+ super(name, parse_param(value))
20
+ end
21
+
22
+ def to_json(opts = {})
23
+ @table.to_json(opts)
24
+ end
25
+
26
+ def method_missing(mid, *args)
27
+ args[0] = parse_param(args[0]) if args[0]
28
+ super
29
+ end
30
+
31
+ def respond_to_missing?(method_name, include_private = false)
32
+ super
33
+ end
34
+
35
+ private
36
+
37
+ def new_ostruct_member!(name)
38
+ name = name.to_sym
39
+ unless singleton_class.method_defined?(name)
40
+ define_singleton_method(name) { @table[name] }
41
+ define_singleton_method("#{name}=") do |x|
42
+ modifiable?[name] = parse_param(x)
43
+ end
44
+ end
45
+ name
46
+ end
47
+
48
+ def parse_param(value)
49
+ value = value.to_s if value.is_a?(Symbol)
50
+ return value unless value.is_a?(String)
51
+
52
+ value[0, IdentityMind.configuration.param_length_limit]
53
+ end
54
+ end
55
+ end
@@ -1,3 +1,3 @@
1
1
  module IdentityMind
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: identity-mind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wojciech Widenka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-25 00:00:00.000000000 Z
11
+ date: 2019-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,6 +91,7 @@ files:
91
91
  - ".rspec"
92
92
  - ".rubocop.yml"
93
93
  - ".travis.yml"
94
+ - CHANGELOG.md
94
95
  - Gemfile
95
96
  - README.md
96
97
  - Rakefile
@@ -100,6 +101,7 @@ files:
100
101
  - lib/identity_mind.rb
101
102
  - lib/identity_mind/account.rb
102
103
  - lib/identity_mind/entity.rb
104
+ - lib/identity_mind/params.rb
103
105
  - lib/identity_mind/response_error.rb
104
106
  - lib/identity_mind/version.rb
105
107
  homepage: https://github.com/BankToTheFuture/identity_mind_ruby