cloudpayments 0.2.0 → 0.2.1
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 +4 -4
- data/README.md +0 -0
- data/lib/cloudpayments/client/request/base.rb +14 -0
- data/lib/cloudpayments/client/request/receipts/create.rb +19 -0
- data/lib/cloudpayments/client/request/receipts/get_status.rb +19 -0
- data/lib/cloudpayments/client/response/base.rb +27 -0
- data/lib/cloudpayments/client/response/body.rb +29 -0
- data/lib/cloudpayments/configuration.rb +11 -0
- data/lib/cloudpayments/connection.rb +27 -0
- metadata +9 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 931cbae2c86bc7b00b5a1033b85a5b48e115154cfd5eb8ebe7e9e7cd11c9d6b7
|
|
4
|
+
data.tar.gz: dcaba5fb29f96b6b49776f7c41af8acaf1674e8a98606ef7fe08e3067641002d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 67d35ff5d338fe6322fc08eac4c4eec56aee77b3132b5222d68b606aba2bb50f737c1f2700709a8a5e412e9e54166f34b5aad8bb4839782c7ecfbbf6e351f639
|
|
7
|
+
data.tar.gz: 3b2123f658aff592ca8e22aa68b19c1b484fa1a9e0bf6226afb97faf95ccd562941c6581e33dd0718f7b5b9f7e3cb71097c89f929c4df0b86291991cd753e69e
|
data/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Cloudpayments
|
|
2
|
+
module Client
|
|
3
|
+
module Request
|
|
4
|
+
class Base
|
|
5
|
+
include Cloudpayments::Connection
|
|
6
|
+
|
|
7
|
+
def self.call(*args, &block)
|
|
8
|
+
response = new(*args, &block).call
|
|
9
|
+
Cloudpayments::Client::Response::Base.new(response)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Cloudpayments
|
|
2
|
+
module Client
|
|
3
|
+
module Request
|
|
4
|
+
module Receipts
|
|
5
|
+
class Create < Cloudpayments::Client::Request::Base
|
|
6
|
+
attr_reader :params
|
|
7
|
+
|
|
8
|
+
def initialize(params)
|
|
9
|
+
@params = params
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def call
|
|
13
|
+
post("kkt/receipt", params)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Cloudpayments
|
|
2
|
+
module Client
|
|
3
|
+
module Request
|
|
4
|
+
module Receipts
|
|
5
|
+
class GetStatus < Cloudpayments::Client::Request::Base
|
|
6
|
+
attr_reader :id
|
|
7
|
+
|
|
8
|
+
def initialize(id)
|
|
9
|
+
@id = id
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def call
|
|
13
|
+
post("kkt/receipt/status/get", { Id: id })
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Cloudpayments
|
|
2
|
+
module Client
|
|
3
|
+
module Response
|
|
4
|
+
class Base
|
|
5
|
+
attr_reader :response
|
|
6
|
+
|
|
7
|
+
def initialize(response)
|
|
8
|
+
@response = response
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def success?
|
|
12
|
+
response.success? && body.success?
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def body
|
|
16
|
+
@_body ||= Body.new(response)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def error
|
|
20
|
+
return if success?
|
|
21
|
+
return response.reason_phrase unless response.success?
|
|
22
|
+
body.message
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Cloudpayments
|
|
2
|
+
module Client
|
|
3
|
+
module Response
|
|
4
|
+
class Body
|
|
5
|
+
attr_reader :body
|
|
6
|
+
|
|
7
|
+
def initialize(response)
|
|
8
|
+
@body = JSON.parse(response.body)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def message
|
|
12
|
+
body["Message"]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def model
|
|
16
|
+
body["Model"]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def model_id
|
|
20
|
+
model["Id"]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def success?
|
|
24
|
+
body["Success"]
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Cloudpayments
|
|
2
|
+
module Connection
|
|
3
|
+
def post(path, data = {})
|
|
4
|
+
request(:post, path, data)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
private
|
|
8
|
+
|
|
9
|
+
def request(method, path, data)
|
|
10
|
+
connection.send(method) do |req|
|
|
11
|
+
req.url path
|
|
12
|
+
req.headers["Content-Type"] = "application/json"
|
|
13
|
+
req.body = data.to_json
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def connection
|
|
18
|
+
conn = Faraday.new(config.base_url)
|
|
19
|
+
conn.basic_auth(config.login, config.password)
|
|
20
|
+
conn
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def config
|
|
24
|
+
Cloudpayments.configuration
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cloudpayments
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexey Spiridonov
|
|
@@ -16,7 +16,15 @@ executables: []
|
|
|
16
16
|
extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
|
18
18
|
files:
|
|
19
|
+
- README.md
|
|
19
20
|
- lib/cloudpayments.rb
|
|
21
|
+
- lib/cloudpayments/client/request/base.rb
|
|
22
|
+
- lib/cloudpayments/client/request/receipts/create.rb
|
|
23
|
+
- lib/cloudpayments/client/request/receipts/get_status.rb
|
|
24
|
+
- lib/cloudpayments/client/response/base.rb
|
|
25
|
+
- lib/cloudpayments/client/response/body.rb
|
|
26
|
+
- lib/cloudpayments/configuration.rb
|
|
27
|
+
- lib/cloudpayments/connection.rb
|
|
20
28
|
homepage: https://rubygems.org/gems/cloudpayments
|
|
21
29
|
licenses:
|
|
22
30
|
- MIT
|