binking 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/binking/client.rb +41 -0
- data/lib/binking/config.rb +25 -0
- data/lib/binking/fields.rb +32 -0
- data/lib/binking/request_resource.rb +24 -0
- data/lib/binking/version.rb +5 -0
- data/lib/binking.rb +37 -0
- metadata +78 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 87ae8c08d0cc8dc974c5525933e04ec4041ebb6d512d249594bdeeb6d6c08230
|
4
|
+
data.tar.gz: fa23a25dbfb6c7623b99703afe96e5d3c8a639935fcd35dabf013b6a4c202ac2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 61e0fd7cde8b7b26fb7f3340580fc86918f510aab98d411148d892ece7cd28936859799cd785e2a8f8fb7af12cb049ba5c056dd1f3bd55301cf4a51c12b88585
|
7
|
+
data.tar.gz: c849c7c63eae4a3d8218382ee453671a84cae07671ea08711992ef895aedee3de8c9592caa3f80b9143db5a07a99ea0204349cebc03ab52104769eaa1557eaaa
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "faraday"
|
4
|
+
|
5
|
+
module Binking
|
6
|
+
class Client
|
7
|
+
attr_accessor :api_token, :host, :sandbox, :cache, :logger
|
8
|
+
|
9
|
+
def initialize(api_token: Binking.config.api_token,
|
10
|
+
host: Binking.config.host,
|
11
|
+
sandbox: Binking.config.sandbox,
|
12
|
+
cache: Binking.config.cache,
|
13
|
+
logger: Binking.config.logger)
|
14
|
+
@api_token = api_token
|
15
|
+
@host = host
|
16
|
+
@sandbox = sandbox
|
17
|
+
@cache = cache
|
18
|
+
@logger = logger
|
19
|
+
end
|
20
|
+
|
21
|
+
def get(path, params = nil)
|
22
|
+
connection.get(path.gsub(%r{^/}, ""), params) do |req|
|
23
|
+
req.params["apiKey"] = api_token if api_token
|
24
|
+
req.params["sandbox"] = 1 if sandbox
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def connection
|
31
|
+
@connection ||= Faraday.new(url: host) do |builder|
|
32
|
+
builder.use(FaradayMiddleware::Caching, cache) if cache
|
33
|
+
builder.use Faraday::Response::RaiseError
|
34
|
+
builder.request :url_encoded
|
35
|
+
builder.response :json
|
36
|
+
builder.response(:logger, logger, { headers: true, bodies: true }) if logger
|
37
|
+
builder.adapter Faraday.default_adapter
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Binking
|
4
|
+
class Config
|
5
|
+
DEFAULT_HOST = "https://api.binking.io"
|
6
|
+
|
7
|
+
attr_accessor :api_token, :host, :sandbox, :cache, :logger
|
8
|
+
|
9
|
+
def initialize(api_token: nil,
|
10
|
+
host: DEFAULT_HOST,
|
11
|
+
sandbox: false,
|
12
|
+
cache: nil,
|
13
|
+
logger: nil)
|
14
|
+
@api_token = api_token
|
15
|
+
@host = host
|
16
|
+
@sandbox = sandbox
|
17
|
+
@cache = cache
|
18
|
+
@logger = logger
|
19
|
+
end
|
20
|
+
|
21
|
+
def configured?
|
22
|
+
[api_token, host].all? { |param| !param.nil? && !param.empty? }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Binking
|
4
|
+
FIELDS = %w[
|
5
|
+
bankAlias
|
6
|
+
bankName
|
7
|
+
bankLocalName
|
8
|
+
bankLogoBigOriginalSvg
|
9
|
+
bankLogoBigOriginalPng
|
10
|
+
bankLogoBigInvertedSvg
|
11
|
+
bankLogoBigInvertedPng
|
12
|
+
bankLogoSmallOriginalSvg
|
13
|
+
bankLogoSmallOriginalPng
|
14
|
+
bankLogoSmallInvertedSvg
|
15
|
+
bankLogoSmallInvertedPng
|
16
|
+
bankColor
|
17
|
+
bankColors
|
18
|
+
bankCountry
|
19
|
+
bankSite
|
20
|
+
bankPhone
|
21
|
+
formBackgroundColor
|
22
|
+
formBackgroundColors
|
23
|
+
formBackgroundLightness
|
24
|
+
formTextColor
|
25
|
+
formBorderColor
|
26
|
+
formBankLogoBigSvg
|
27
|
+
formBankLogoBigPng
|
28
|
+
formBankLogoSmallSvg
|
29
|
+
formBankLogoSmallPng
|
30
|
+
formLogoScheme
|
31
|
+
].freeze
|
32
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Binking
|
4
|
+
module RequestResource
|
5
|
+
extend self
|
6
|
+
|
7
|
+
RESOURCES_KEYS = {
|
8
|
+
"bank" => "bankAlias",
|
9
|
+
"banks" => "banksAliases",
|
10
|
+
"form" => "cardNumber"
|
11
|
+
}.freeze
|
12
|
+
|
13
|
+
def get(resource, value, fields: [], sandbox: false)
|
14
|
+
fields = fields.map(&:to_s) & FIELDS
|
15
|
+
params = {}
|
16
|
+
params[RESOURCES_KEYS[resource.to_s]] = value
|
17
|
+
params[:fields] = fields.join(",") unless fields.empty?
|
18
|
+
|
19
|
+
Client.new(sandbox: sandbox)
|
20
|
+
.get("/#{resource}", params)
|
21
|
+
.body
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/binking.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "binking/version"
|
4
|
+
require "binking/config"
|
5
|
+
require "binking/client"
|
6
|
+
require "binking/fields"
|
7
|
+
require "binking/request_resource"
|
8
|
+
|
9
|
+
module Binking
|
10
|
+
class NotConfiguredError < StandardError; end
|
11
|
+
extend self
|
12
|
+
|
13
|
+
def configure
|
14
|
+
@config ||= Config.new
|
15
|
+
yield @config if block_given?
|
16
|
+
@config
|
17
|
+
end
|
18
|
+
alias_method :config, :configure
|
19
|
+
|
20
|
+
def configured?
|
21
|
+
config.configured?
|
22
|
+
end
|
23
|
+
|
24
|
+
def method_missing(method_name, *args, &block)
|
25
|
+
if %i[form bank banks].include?(method_name)
|
26
|
+
raise NotConfiguredError unless configured?
|
27
|
+
|
28
|
+
RequestResource.get(method_name, *args)
|
29
|
+
else
|
30
|
+
super
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def respond_to_missing?(method_name, include_private = false)
|
35
|
+
connection.respond_to?(method_name) || super
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: binking
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anton Kostyuk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-01-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.7.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.7.1
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- anton.kostuk.2012@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- lib/binking.rb
|
49
|
+
- lib/binking/client.rb
|
50
|
+
- lib/binking/config.rb
|
51
|
+
- lib/binking/fields.rb
|
52
|
+
- lib/binking/request_resource.rb
|
53
|
+
- lib/binking/version.rb
|
54
|
+
homepage: https://github.com/RainbowPonny/ruby-binking
|
55
|
+
licenses:
|
56
|
+
- MIT
|
57
|
+
metadata:
|
58
|
+
rubygems_mfa_required: 'true'
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 2.5.0
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubygems_version: 3.1.6
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: Ruby client for binking.io API
|
78
|
+
test_files: []
|