identity-mind 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 +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +6 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/README.md +50 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/identity_mind.gemspec +29 -0
- data/lib/identity_mind.rb +41 -0
- data/lib/identity_mind/account.rb +5 -0
- data/lib/identity_mind/entity.rb +21 -0
- data/lib/identity_mind/response_error.rb +22 -0
- data/lib/identity_mind/version.rb +3 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 01aeca0539a031175ed24deacc9290d5df921d8110c51d5d5d6fdcb0031fa10e
|
4
|
+
data.tar.gz: e154bb80fd31c7f9943cdddbfb8ae26704b1c72cd25f344f2f4ea13bbfa4b7ae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 838e054f2fbd0bc77375c890b30a183a86c6eb17b4fc78587a468b6105d189ab622d36db473c6f75629b2215e1949287b1a489d57b0a50d1b85f5a8583f3bee2
|
7
|
+
data.tar.gz: 75420c9b73b7229fed953d15a95e1b52ca0008347888caa8c1425ce624d17f7597305a8fa6e7c1b614b4d303f023b0456cf12bae4d952f4e14b3db211cda8f11
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# IdentityMind
|
2
|
+
|
3
|
+
This gem is simple wrapper on Identity Mind API
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'identity_mind'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install identity_mind
|
20
|
+
## Configuration
|
21
|
+
|
22
|
+
In order to make calls to the api you must provide credentials:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
IdentityMind.configure do |config|
|
26
|
+
config.user = ENV['IDENTITY_MIND_USER']
|
27
|
+
config.password = ENV['IDENTITY_MIND_PASSWORD']
|
28
|
+
config.base_uri = ENV['IDENTITY_MIND_URL'] # default: https://edna.identitymind.com
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
IdentityMind::Account::Merchant.create(merchant: 'params')
|
36
|
+
IdentityMind::Account::Merchant.fetch(transaction_id)
|
37
|
+
|
38
|
+
IdentityMind.get('account/metchant/:transaction_id')
|
39
|
+
|
40
|
+
```
|
41
|
+
|
42
|
+
## Development
|
43
|
+
|
44
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
45
|
+
|
46
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/identity_mind.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'identity_mind'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'identity_mind/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'identity-mind'
|
7
|
+
spec.version = IdentityMind::VERSION
|
8
|
+
spec.authors = ['Wojciech Widenka']
|
9
|
+
spec.email = ['wojtek@codegarden.online']
|
10
|
+
|
11
|
+
spec.summary = 'Simple Identity Mind API client.'
|
12
|
+
spec.description = 'Simple Identity Mind API client.'
|
13
|
+
spec.homepage = 'https://github.com/BankToTheFuture/identity_mind_ruby'
|
14
|
+
|
15
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
16
|
+
`git ls-files -z`.split("\x0")
|
17
|
+
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
end
|
19
|
+
spec.bindir = 'exe'
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
|
+
spec.add_development_dependency 'rubocop'
|
27
|
+
|
28
|
+
spec.add_dependency 'httparty', '~>0.16'
|
29
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require 'httparty'
|
3
|
+
require 'identity_mind/version'
|
4
|
+
require 'identity_mind/response_error'
|
5
|
+
require 'identity_mind/entity'
|
6
|
+
require 'identity_mind/account'
|
7
|
+
|
8
|
+
module IdentityMind
|
9
|
+
include HTTParty
|
10
|
+
|
11
|
+
headers 'Content-Type' => 'application/json'
|
12
|
+
format :json
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def configuration
|
16
|
+
@configuration ||= OpenStruct.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def configure
|
20
|
+
yield(configuration)
|
21
|
+
update_config
|
22
|
+
end
|
23
|
+
|
24
|
+
def update_config
|
25
|
+
base_uri configuration.base_uri
|
26
|
+
basic_auth configuration.user, configuration.password
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
def perform_request(http_method, path, options, &block)
|
31
|
+
result = super
|
32
|
+
return result if result.success?
|
33
|
+
|
34
|
+
raise ResponseError.new(result.body, result.code)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
configure do |config|
|
39
|
+
config.base_uri = 'https://edna.identitymind.com'
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module IdentityMind
|
2
|
+
class Entity < OpenStruct
|
3
|
+
def initialize(json_payload)
|
4
|
+
super(JSON.parse(json_payload, symbolize_names: true))
|
5
|
+
end
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def path
|
9
|
+
"/im/#{to_s.split('::')[1..-1].map!(&:downcase).join('/')}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def create(params)
|
13
|
+
new(IdentityMind.post(path, body: params.to_json).body)
|
14
|
+
end
|
15
|
+
|
16
|
+
def fetch(transaction_id)
|
17
|
+
new(IdentityMind.get("#{path}/#{transaction_id}").body)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module IdentityMind
|
2
|
+
class ResponseError < StandardError
|
3
|
+
attr_reader :body, :code, :error_message
|
4
|
+
|
5
|
+
def initialize(body, code)
|
6
|
+
@code = code
|
7
|
+
@body = body
|
8
|
+
@error_message = extract_error_message(body)
|
9
|
+
|
10
|
+
super(
|
11
|
+
["IdentityMind responded with status #{code}", @error_message]
|
12
|
+
.compact.join(' => ')
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def extract_error_message(body)
|
17
|
+
JSON.parse(body)['error_message']
|
18
|
+
rescue JSON::ParserError
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: identity-mind
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wojciech Widenka
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: httparty
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.16'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.16'
|
83
|
+
description: Simple Identity Mind API client.
|
84
|
+
email:
|
85
|
+
- wojtek@codegarden.online
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".rubocop.yml"
|
93
|
+
- ".travis.yml"
|
94
|
+
- Gemfile
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/console
|
98
|
+
- bin/setup
|
99
|
+
- identity_mind.gemspec
|
100
|
+
- lib/identity_mind.rb
|
101
|
+
- lib/identity_mind/account.rb
|
102
|
+
- lib/identity_mind/entity.rb
|
103
|
+
- lib/identity_mind/response_error.rb
|
104
|
+
- lib/identity_mind/version.rb
|
105
|
+
homepage: https://github.com/BankToTheFuture/identity_mind_ruby
|
106
|
+
licenses: []
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubygems_version: 3.0.3
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Simple Identity Mind API client.
|
127
|
+
test_files: []
|