smartcoin 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/lib/data/shipping-ssl-bundle.crt +124 -0
- data/lib/data/ssl-bundle.crt +123 -0
- data/lib/smartcoin/api_operations/create.rb +16 -0
- data/lib/smartcoin/api_operations/list.rb +16 -0
- data/lib/smartcoin/api_operations/retrieve.rb +16 -0
- data/lib/smartcoin/api_operations/update.rb +12 -0
- data/lib/smartcoin/api_resource.rb +56 -0
- data/lib/smartcoin/card.rb +4 -0
- data/lib/smartcoin/charge.rb +21 -0
- data/lib/smartcoin/errors/smart_coin_error.rb +12 -0
- data/lib/smartcoin/fee.rb +4 -0
- data/lib/smartcoin/installment.rb +4 -0
- data/lib/smartcoin/refund.rb +4 -0
- data/lib/smartcoin/shipping.rb +35 -0
- data/lib/smartcoin/smart_coin_object.rb +85 -0
- data/lib/smartcoin/token.rb +7 -0
- data/lib/smartcoin/util.rb +34 -0
- data/lib/smartcoin/version.rb +3 -0
- data/lib/smartcoin.rb +36 -0
- data/smartcoin.gemspec +26 -0
- data/test/rspec_helper.rb +2 -0
- data/test/smartcoin/api_resource_spec.rb +52 -0
- data/test/smartcoin/card_spec.rb +33 -0
- data/test/smartcoin/charge_spec.rb +172 -0
- data/test/smartcoin/shipping_calculator_spec.rb +24 -0
- data/test/smartcoin/smart_coin_spec.rb +45 -0
- data/test/smartcoin/token_spec.rb +21 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 66d59c05f21dabf328880f362f1bfc4059372360
|
4
|
+
data.tar.gz: 29f7744e88763a98804d659803ded56ba5e2827a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b472a18ae5b0e4143d5d3f4aca62daa359af8bb795a293434ebf00c013d54117fa5394d6406eaf0bb9d1fd4cced4368045ca3c5732ea72082ac16083e733339f
|
7
|
+
data.tar.gz: 47e35143187753c56e0c6ce3c5e5a2bc2a2a7e506fcb4997138a6c825246c411572ab1a95eba470f9333d030451ce6760727546916e3e3398170e58c315e2109
|
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.idea
|
24
|
+
.DS_Store
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
smartcoin
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.1
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 agranado
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Smartcoin
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'smartcoin'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install smartcoin
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/smartcoin/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIFcDCCBFigAwIBAgIQFX0aCi5Q4U49WvE0lmY3wTANBgkqhkiG9w0BAQsFADCB
|
3
|
+
kDELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G
|
4
|
+
A1UEBxMHU2F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QwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv77+ldU9U0
|
112
|
+
WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD
|
113
|
+
VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0
|
114
|
+
Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRU
|
115
|
+
cnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsx
|
116
|
+
IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN
|
117
|
+
AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH
|
118
|
+
YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5
|
119
|
+
6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC
|
120
|
+
Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX
|
121
|
+
c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a
|
122
|
+
mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ=
|
123
|
+
-----END CERTIFICATE-----
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module SmartCoin
|
2
|
+
module ApiOperations
|
3
|
+
module Create
|
4
|
+
def create(params)
|
5
|
+
url = get_url
|
6
|
+
method = :post
|
7
|
+
response = api_request(url,method,params)
|
8
|
+
create_from(response)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.included(base)
|
12
|
+
base.extend(Create)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module SmartCoin
|
2
|
+
module ApiOperations
|
3
|
+
module List
|
4
|
+
def list_all(params)
|
5
|
+
url = get_url
|
6
|
+
method = :get
|
7
|
+
response = api_request(url, method, params)
|
8
|
+
create_from(response)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.included(base)
|
12
|
+
base.extend(List)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module SmartCoin
|
2
|
+
module ApiOperations
|
3
|
+
module Retrieve
|
4
|
+
def retrieve(charge_id)
|
5
|
+
url = get_url
|
6
|
+
method = :get
|
7
|
+
response = api_request("#{url}/#{charge_id}",method)
|
8
|
+
create_from(response)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.included(base)
|
12
|
+
base.extend(Retrieve)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module SmartCoin
|
2
|
+
module ApiOperations
|
3
|
+
module Update
|
4
|
+
def update(smartcoin_object_id, url_sufix, params=nil)
|
5
|
+
url = "#{self.class.get_url()}/#{smartcoin_object_id}#{url_sufix}"
|
6
|
+
method = :post
|
7
|
+
response = api_request(url,method,params)
|
8
|
+
reflesh_object(response)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module SmartCoin
|
2
|
+
module ApiResource
|
3
|
+
BASE_URL = 'https://api.smartcoin.com.br'
|
4
|
+
SSL_BUNDLE_PATH = File.dirname(__FILE__) + '/../data/ssl-bundle.crt'
|
5
|
+
|
6
|
+
def url_encode(key)
|
7
|
+
URI.escape(key.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
|
8
|
+
end
|
9
|
+
|
10
|
+
def encode(params)
|
11
|
+
params.map { |k,v| "#{k}=#{url_encode(v)}" }.join('&')
|
12
|
+
end
|
13
|
+
|
14
|
+
def api_request(url, method, params=nil)
|
15
|
+
url = "#{BASE_URL}#{url}"
|
16
|
+
if method == :get && params
|
17
|
+
params_encoded = encode(params)
|
18
|
+
url = "#{url}?#{params_encoded}"
|
19
|
+
params = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
access_keys = SmartCoin.access_keys.split(':')
|
23
|
+
api_key = access_keys[0]
|
24
|
+
api_secret = access_keys[1]
|
25
|
+
begin
|
26
|
+
response = RestClient::Request.new(
|
27
|
+
method: method,
|
28
|
+
url: url,
|
29
|
+
user: api_key,
|
30
|
+
password: api_secret,
|
31
|
+
payload: params,
|
32
|
+
headers: { accept: :json,
|
33
|
+
content_type: :json },
|
34
|
+
verify_ssl: OpenSSL::SSL::VERIFY_PEER,
|
35
|
+
ssl_ca_file: SSL_BUNDLE_PATH
|
36
|
+
).execute
|
37
|
+
rescue RestClient::ExceptionWithResponse => e
|
38
|
+
if rcode = e.http_code and rbody = e.http_body
|
39
|
+
rbody = JSON.parse(rbody)
|
40
|
+
rbody = Util.symbolize_names(rbody)
|
41
|
+
|
42
|
+
raise SmartCoinError.new(rcode, rbody, rbody[:error], rbody[:error][:message])
|
43
|
+
else
|
44
|
+
raise e
|
45
|
+
end
|
46
|
+
rescue RestClient::Exception => e
|
47
|
+
raise e
|
48
|
+
end
|
49
|
+
JSON.parse(response.to_str)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.included(base)
|
53
|
+
base.extend(ApiResource)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module SmartCoin
|
2
|
+
class Charge < SmartCoinObject
|
3
|
+
include ApiResource
|
4
|
+
include ApiOperations::Create
|
5
|
+
include ApiOperations::Retrieve
|
6
|
+
include ApiOperations::Update
|
7
|
+
include ApiOperations::List
|
8
|
+
|
9
|
+
def capture(amount=nil)
|
10
|
+
url_sufix = '/capture'
|
11
|
+
params = {amount: amount} if amount
|
12
|
+
update(self.id, url_sufix, params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def refund(amount=nil)
|
16
|
+
url_sufix = '/refund'
|
17
|
+
params = {amount: amount} if amount
|
18
|
+
update(self.id, url_sufix, params)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module SmartCoin
|
2
|
+
class SmartCoinError < StandardError
|
3
|
+
attr_reader :http_status, :json_message, :http_message, :message
|
4
|
+
|
5
|
+
def initialize(http_status=nil, json_message=nil, http_message=nil, message=nil)
|
6
|
+
@http_status = http_status
|
7
|
+
@json_message = json_message
|
8
|
+
@http_message = http_message
|
9
|
+
@message = message
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module SmartCoin
|
2
|
+
class Shipping
|
3
|
+
BASE_SHIPPING_URL = 'https://shipping.smartcoin.com.br'
|
4
|
+
SSL_BUNDLE_PATH = File.dirname(__FILE__) + '/../data/shipping-ssl-bundle.crt'
|
5
|
+
|
6
|
+
def self.calculator(params)
|
7
|
+
method = :get
|
8
|
+
url = BASE_SHIPPING_URL + '/shipping_calculator/'
|
9
|
+
|
10
|
+
begin
|
11
|
+
response = RestClient::Request.new(
|
12
|
+
method: method,
|
13
|
+
url: url,
|
14
|
+
payload: params,
|
15
|
+
headers: { accept: :json,
|
16
|
+
content_type: :json },
|
17
|
+
verify_ssl: OpenSSL::SSL::VERIFY_PEER,
|
18
|
+
ssl_ca_file: SSL_BUNDLE_PATH
|
19
|
+
).execute
|
20
|
+
rescue RestClient::ExceptionWithResponse => e
|
21
|
+
if rcode = e.http_code and rbody = e.http_body
|
22
|
+
rbody = JSON.parse(rbody)
|
23
|
+
rbody = Util.symbolize_names(rbody)
|
24
|
+
|
25
|
+
raise SmartCoinError.new(rcode, rbody, rbody[:error], rbody[:error][:message])
|
26
|
+
else
|
27
|
+
raise e
|
28
|
+
end
|
29
|
+
rescue RestClient::Exception => e
|
30
|
+
raise e
|
31
|
+
end
|
32
|
+
JSON.parse(response.to_str).inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module SmartCoin
|
2
|
+
class SmartCoinObject
|
3
|
+
@values
|
4
|
+
def metaclass
|
5
|
+
class << self; self; end
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.create_from(params)
|
9
|
+
obj = self.new
|
10
|
+
obj.reflesh_object(params)
|
11
|
+
end
|
12
|
+
|
13
|
+
def reflesh_object(params)
|
14
|
+
create_fields(params)
|
15
|
+
set_properties(params)
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_fields(params)
|
20
|
+
instance_eval do
|
21
|
+
metaclass.instance_eval do
|
22
|
+
params.keys.each do |key|
|
23
|
+
define_method(key) { @values[key] }
|
24
|
+
|
25
|
+
define_method("#{key}=") do |value|
|
26
|
+
@values[key] = value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def set_properties(params)
|
34
|
+
instance_eval do
|
35
|
+
params.each do |key, value|
|
36
|
+
if value.class == Hash
|
37
|
+
@values[key] = Util.get_object_type(value['object']).create_from(value)
|
38
|
+
elsif value.class == Array
|
39
|
+
@values[key] = value.map{ |v| Util.get_object_type(v['object']).create_from(v) }
|
40
|
+
else
|
41
|
+
@values[key] = value
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.get_url
|
48
|
+
"/v1/#{CGI.escape(class_name.downcase)}s"
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.class_name
|
52
|
+
self.name.split('::')[-1]
|
53
|
+
end
|
54
|
+
|
55
|
+
def initialize()
|
56
|
+
@values = {}
|
57
|
+
end
|
58
|
+
|
59
|
+
def to_hash
|
60
|
+
@values.inject({}) do |result, (key,value)|
|
61
|
+
if value.is_a? Array
|
62
|
+
list = []
|
63
|
+
value.each do |obj|
|
64
|
+
list.push(obj.respond_to?(:to_hash) ? obj.to_hash : value)
|
65
|
+
end
|
66
|
+
result[key] = list
|
67
|
+
else if value.respond_to?(:to_hash)
|
68
|
+
result[key] = value.to_hash
|
69
|
+
else
|
70
|
+
result[key] = value
|
71
|
+
end
|
72
|
+
end
|
73
|
+
result
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def to_json(*a)
|
78
|
+
JSON.generate(@values)
|
79
|
+
end
|
80
|
+
|
81
|
+
def to_s
|
82
|
+
JSON.generate(@values)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module SmartCoin
|
2
|
+
class Util
|
3
|
+
OBJECT_TYPES = {
|
4
|
+
'card' => SmartCoin::Card,
|
5
|
+
'charge' => SmartCoin::Charge,
|
6
|
+
'refund' => SmartCoin::Refund,
|
7
|
+
'fee' => SmartCoin::Fee,
|
8
|
+
'installment' => SmartCoin::Installment,
|
9
|
+
'Token' => SmartCoin::Token,
|
10
|
+
}
|
11
|
+
|
12
|
+
def self.get_object_type(type)
|
13
|
+
object_type = SmartCoin::SmartCoinObject
|
14
|
+
object_type = OBJECT_TYPES[type] if OBJECT_TYPES[type]
|
15
|
+
object_type
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.symbolize_names(object)
|
19
|
+
case object
|
20
|
+
when Hash
|
21
|
+
new = {}
|
22
|
+
object.each do |key, value|
|
23
|
+
key = (key.to_sym rescue key) || key
|
24
|
+
new[key] = symbolize_names(value)
|
25
|
+
end
|
26
|
+
new
|
27
|
+
when Array
|
28
|
+
object.map { |value| symbolize_names(value) }
|
29
|
+
else
|
30
|
+
object
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/smartcoin.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require "rest-client"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
require "smartcoin/version"
|
5
|
+
require "smartcoin/smart_coin_object"
|
6
|
+
require "smartcoin/api_resource"
|
7
|
+
require "smartcoin/api_operations/create"
|
8
|
+
require "smartcoin/api_operations/retrieve"
|
9
|
+
require "smartcoin/api_operations/update"
|
10
|
+
require "smartcoin/api_operations/list"
|
11
|
+
require "smartcoin/card"
|
12
|
+
require "smartcoin/token"
|
13
|
+
require "smartcoin/refund"
|
14
|
+
require "smartcoin/fee"
|
15
|
+
require "smartcoin/installment"
|
16
|
+
require "smartcoin/charge"
|
17
|
+
require "smartcoin/util"
|
18
|
+
require "smartcoin/errors/smart_coin_error"
|
19
|
+
require "smartcoin/shipping"
|
20
|
+
|
21
|
+
module SmartCoin
|
22
|
+
@@api_key = ''
|
23
|
+
@@api_secret = ''
|
24
|
+
|
25
|
+
def self.api_key(api_key)
|
26
|
+
@@api_key = api_key
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.api_secret(api_secret)
|
30
|
+
@@api_secret = api_secret
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.access_keys
|
34
|
+
"#{@@api_key}:#{@@api_secret}"
|
35
|
+
end
|
36
|
+
end
|
data/smartcoin.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'smartcoin/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "smartcoin"
|
8
|
+
spec.version = Smartcoin::VERSION
|
9
|
+
spec.authors = ["Arthur Granado"]
|
10
|
+
spec.email = ["agranado@smartcoin.com.br"]
|
11
|
+
spec.summary = %q{Ruby bind to SmartCoin API}
|
12
|
+
spec.description = %q{Ruby library to SmartCoin API - https://smartcoin.com.br}
|
13
|
+
spec.homepage = "https://smartcoin.com.br"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "rest-client", "~> 1.6.7"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec", "~> 2.14.0"
|
26
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require_relative '../rspec_helper'
|
2
|
+
|
3
|
+
describe SmartCoin::ApiResource do
|
4
|
+
before(:each) do
|
5
|
+
SmartCoin.api_key('pk_test_3ac0794848c339')
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'call SmartCoin API' do
|
9
|
+
url = "/v1/tokens"
|
10
|
+
method = :post
|
11
|
+
|
12
|
+
params = {number: 4242424242424242,
|
13
|
+
exp_month: 11,
|
14
|
+
exp_year: 2017,
|
15
|
+
cvc: 111,
|
16
|
+
name: 'Arthur Granado'
|
17
|
+
}
|
18
|
+
response = SmartCoin::Token.api_request(url, method, params)
|
19
|
+
expect(response['id']).to match(/tok_(.*)/)
|
20
|
+
expect(response['object']).to eq('token')
|
21
|
+
expect(response['card']['last4']).to eq('4242')
|
22
|
+
expect(response['card']['exp_month']).to eq(11)
|
23
|
+
expect(response['card']['exp_year']).to eq(2017)
|
24
|
+
expect(response['card']['name']).to eq('Arthur Granado')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should throw error' do
|
28
|
+
url = "/v1/tokens"
|
29
|
+
method = :post
|
30
|
+
|
31
|
+
params = {exp_month: 11,
|
32
|
+
exp_year: 2017,
|
33
|
+
cvc: 111,
|
34
|
+
name: 'Arthur Granado'
|
35
|
+
}
|
36
|
+
|
37
|
+
expect{ SmartCoin::Token.api_request(url, method, params) }.to raise_error SmartCoin::SmartCoinError
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should create SmartCoinError with error message and http code' do
|
42
|
+
http_code = 400
|
43
|
+
json_message = {error: {type: '', message: ''}}
|
44
|
+
http_message = ''
|
45
|
+
message = ''
|
46
|
+
smartcoin_error = SmartCoin::SmartCoinError.new(http_code, json_message, http_message, message)
|
47
|
+
expect(smartcoin_error.http_status).to eq(http_code)
|
48
|
+
expect(smartcoin_error.json_message).to eq(json_message)
|
49
|
+
expect(smartcoin_error.http_message).to eq(http_message)
|
50
|
+
expect(smartcoin_error.message).to eq(message)
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../rspec_helper'
|
2
|
+
|
3
|
+
describe SmartCoin::Card do
|
4
|
+
|
5
|
+
it 'should create a card object from hash' do
|
6
|
+
card_json = {
|
7
|
+
id: "card_23437598768758814",
|
8
|
+
object: "card",
|
9
|
+
last4: "4242",
|
10
|
+
type: "Visa",
|
11
|
+
exp_month: 11,
|
12
|
+
exp_year: 2017,
|
13
|
+
fingerprint: "8535531490d032bf2268c1b4e708655c0287e07017ea19ae79e704c831b27fa6",
|
14
|
+
country: "BR",
|
15
|
+
name: "Arthur Granado",
|
16
|
+
address_line1: nil,
|
17
|
+
address_line2: nil,
|
18
|
+
address_city: nil,
|
19
|
+
address_state: nil,
|
20
|
+
address_cep: nil,
|
21
|
+
address_country: nil
|
22
|
+
}
|
23
|
+
|
24
|
+
card = SmartCoin::Card.create_from(card_json)
|
25
|
+
expect(card.id).to eq(card_json[:id])
|
26
|
+
expect(card.object).to eq(card_json[:object])
|
27
|
+
expect(card.last4).to eq(card_json[:last4])
|
28
|
+
expect(card.exp_month).to eq(card_json[:exp_month])
|
29
|
+
expect(card.exp_year).to eq(card_json[:exp_year])
|
30
|
+
expect(card.fingerprint).to eq(card_json[:fingerprint])
|
31
|
+
expect(card.name).to eq(card_json[:name])
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
|
3
|
+
describe SmartCoin::Charge do
|
4
|
+
before(:each) do
|
5
|
+
SmartCoin.api_key('pk_test_3ac0794848c339')
|
6
|
+
SmartCoin.api_secret('sk_test_8bec997b7a0ea1')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should create a charge' do
|
10
|
+
token_params = {number: 4242424242424242,
|
11
|
+
exp_month: 11,
|
12
|
+
exp_year: 2017,
|
13
|
+
cvc: '111',
|
14
|
+
name: 'Arthur Granado'
|
15
|
+
}
|
16
|
+
token = SmartCoin::Token.create(token_params)
|
17
|
+
charge_params = {
|
18
|
+
amount: 1000,
|
19
|
+
currency: 'brl',
|
20
|
+
card: token.id,
|
21
|
+
}
|
22
|
+
|
23
|
+
charge = SmartCoin::Charge.create(charge_params)
|
24
|
+
expect(charge.id).to match(/ch_(.*)/)
|
25
|
+
expect(charge.amount).to eq(charge_params[:amount])
|
26
|
+
expect(charge.paid).to be_true
|
27
|
+
expect(charge.captured).to be_true
|
28
|
+
expect(charge.card.id).to match(/card_(.*)/)
|
29
|
+
expect(charge.card.type).to eq('Visa')
|
30
|
+
expect(charge.fees).to have_at_least(2).items
|
31
|
+
expect(charge.fees.first.type).to eq('SmartCoin fee: flat')
|
32
|
+
expect(charge.fees.first.class).to eq(SmartCoin::Fee)
|
33
|
+
expect(charge.installments).to have_at_least(1).item
|
34
|
+
expect(charge.installments.first.class).to eq(SmartCoin::Installment)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should create a bank_slip charge types' do
|
38
|
+
charge_params = {amount: 1000, currency: 'brl', type: 'bank_slip'}
|
39
|
+
charge = SmartCoin::Charge.create(charge_params)
|
40
|
+
expect(charge.id).to match(/ch_(.*)/)
|
41
|
+
expect(charge.amount).to eq(charge_params[:amount])
|
42
|
+
expect(charge.paid).to be_false
|
43
|
+
expect(charge.card).to be_nil
|
44
|
+
expect(charge.bank_slip).to_not be_nil
|
45
|
+
expect(charge.bank_slip.link).to match(/https:\/\/api\.smartcoin\.com\.br\/v1\/charges\/ch_(.*)\/bank_slip\/test/)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should retrieve a charge that has already created' do
|
49
|
+
token_params = {number: 4242424242424242,
|
50
|
+
exp_month: 11,
|
51
|
+
exp_year: 2017,
|
52
|
+
cvc: '111',
|
53
|
+
name: 'Arthur Granado'
|
54
|
+
}
|
55
|
+
token = SmartCoin::Token.create(token_params)
|
56
|
+
charge_params = {
|
57
|
+
amount: 1000,
|
58
|
+
currency: 'brl',
|
59
|
+
card: token.id,
|
60
|
+
}
|
61
|
+
|
62
|
+
charge_created = SmartCoin::Charge.create(charge_params)
|
63
|
+
charge_retrieved = SmartCoin::Charge.retrieve(charge_created.id)
|
64
|
+
expect(charge_retrieved.id).to eq(charge_created.id)
|
65
|
+
expect(charge_retrieved.amount).to eq(charge_created.amount)
|
66
|
+
expect(charge_retrieved.card.fingerprint).to eq(charge_created.card.fingerprint)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should capture charge that has already created' do
|
70
|
+
token_params = {number: 4242424242424242,
|
71
|
+
exp_month: 11,
|
72
|
+
exp_year: 2017,
|
73
|
+
cvc: '111',
|
74
|
+
name: 'Arthur Granado'
|
75
|
+
}
|
76
|
+
token = SmartCoin::Token.create(token_params)
|
77
|
+
charge_params = {
|
78
|
+
amount: 1000,
|
79
|
+
currency: 'brl',
|
80
|
+
card: token.id,
|
81
|
+
capture: false
|
82
|
+
}
|
83
|
+
|
84
|
+
charge_created = SmartCoin::Charge.create(charge_params)
|
85
|
+
expect(charge_created.captured).to be_false
|
86
|
+
charge_created.capture()
|
87
|
+
expect(charge_created.captured).to be_true
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should partial capture charge that has already created' do
|
91
|
+
token_params = {number: 4242424242424242,
|
92
|
+
exp_month: 11,
|
93
|
+
exp_year: 2017,
|
94
|
+
cvc: '111',
|
95
|
+
name: 'Arthur Granado'
|
96
|
+
}
|
97
|
+
token = SmartCoin::Token.create(token_params)
|
98
|
+
charge_params = {
|
99
|
+
amount: 1000,
|
100
|
+
currency: 'brl',
|
101
|
+
card: token.id,
|
102
|
+
capture: false
|
103
|
+
}
|
104
|
+
|
105
|
+
charge_created = SmartCoin::Charge.create(charge_params)
|
106
|
+
expect(charge_created.captured).to be_false
|
107
|
+
amount_captured = 300
|
108
|
+
charge_created.capture(amount_captured)
|
109
|
+
expect(charge_created.captured).to be_true
|
110
|
+
expect(charge_created.amount).to eq(charge_params[:amount])
|
111
|
+
expect(charge_created.amount_refunded).to eq(charge_params[:amount] - amount_captured)
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should refund charge that has already created' do
|
115
|
+
token_params = {number: 4242424242424242,
|
116
|
+
exp_month: 11,
|
117
|
+
exp_year: 2017,
|
118
|
+
cvc: '111',
|
119
|
+
name: 'Arthur Granado'
|
120
|
+
}
|
121
|
+
token = SmartCoin::Token.create(token_params)
|
122
|
+
charge_params = {
|
123
|
+
amount: 1000,
|
124
|
+
currency: 'brl',
|
125
|
+
card: token.id
|
126
|
+
}
|
127
|
+
|
128
|
+
charge_created = SmartCoin::Charge.create(charge_params)
|
129
|
+
expect(charge_created.refunded).to be_false
|
130
|
+
|
131
|
+
charge_created.refund()
|
132
|
+
expect(charge_created.refunded).to be_true
|
133
|
+
expect(charge_created.amount).to eq(charge_params[:amount])
|
134
|
+
expect(charge_created.amount_refunded).to eq(charge_params[:amount])
|
135
|
+
expect(charge_created.refunds).to have(1).item
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'should partial refund charge that has already created' do
|
139
|
+
token_params = {number: 4242424242424242,
|
140
|
+
exp_month: 11,
|
141
|
+
exp_year: 2017,
|
142
|
+
cvc: '111',
|
143
|
+
name: 'Arthur Granado'
|
144
|
+
}
|
145
|
+
token = SmartCoin::Token.create(token_params)
|
146
|
+
charge_params = {
|
147
|
+
amount: 1000,
|
148
|
+
currency: 'brl',
|
149
|
+
card: token.id
|
150
|
+
}
|
151
|
+
|
152
|
+
charge_created = SmartCoin::Charge.create(charge_params)
|
153
|
+
expect(charge_created.refunded).to be_false
|
154
|
+
|
155
|
+
amount_refunded = 600
|
156
|
+
charge_created.refund(amount_refunded)
|
157
|
+
expect(charge_created.refunded).to be_false
|
158
|
+
expect(charge_created.amount).to eq(charge_params[:amount])
|
159
|
+
expect(charge_created.amount_refunded).to eq(amount_refunded)
|
160
|
+
expect(charge_created.refunds).to have(1).item
|
161
|
+
expect(charge_created.refunds[0].amount).to eq(amount_refunded)
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should list charges that have already created' do
|
165
|
+
params = {count: 3}
|
166
|
+
charge_list = SmartCoin::Charge.list_all(params)
|
167
|
+
expect(charge_list.object).to eq('list')
|
168
|
+
expect(charge_list.count).to eq(3)
|
169
|
+
expect(charge_list.data).to have(3).items
|
170
|
+
expect(charge_list.data[0].class).to eq(SmartCoin::Charge)
|
171
|
+
end
|
172
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
|
3
|
+
describe SmartCoin::Shipping do
|
4
|
+
|
5
|
+
it 'should calculate a shipping cost (destination_cep 36.600-000)' do
|
6
|
+
weight = 0.2 # Kg
|
7
|
+
origin_cep = 22280100 #RJ - Rio de Janeiro - Botafogo
|
8
|
+
destination_cep = 36600000 #MG - Bicas
|
9
|
+
expect_shipping_cost = 1650 #the current value that correios charge for PAC service without deal
|
10
|
+
|
11
|
+
shipping_info = SmartCoin::Shipping.calculator(weight: weight, origin_cep: origin_cep, destination_cep: destination_cep)
|
12
|
+
expect(shipping_info[:amount]).to eq(expect_shipping_cost)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should calculate a shipping cost with different destination_cep (24.230-153)' do
|
16
|
+
weight = 0.2 # Kg
|
17
|
+
origin_cep = 22280100 #RJ - Rio de Janeiro - Botafogo
|
18
|
+
destination_cep = 24230153 #RJ - Niterói - Icaraí
|
19
|
+
expect_shipping_cost = 1370 #the current value that correios charge for PAC service without deal
|
20
|
+
|
21
|
+
shipping_info = SmartCoin::Shipping.calculator(weight: weight, origin_cep: origin_cep, destination_cep: destination_cep)
|
22
|
+
expect(shipping_info[:amount]).to eq(expect_shipping_cost)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative '../rspec_helper'
|
2
|
+
|
3
|
+
describe SmartCoin do
|
4
|
+
|
5
|
+
it 'should set api key' do
|
6
|
+
SmartCoin.api_key('pk_test_1234')
|
7
|
+
SmartCoin.api_secret('')
|
8
|
+
expect(SmartCoin.access_keys).to eq('pk_test_1234:')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should set api secret' do
|
12
|
+
SmartCoin.api_key('')
|
13
|
+
SmartCoin.api_secret('sk_test_1234')
|
14
|
+
expect(SmartCoin.access_keys).to eq(':sk_test_1234')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should get empty access keys' do
|
18
|
+
SmartCoin.api_key('')
|
19
|
+
SmartCoin.api_secret('')
|
20
|
+
expect(SmartCoin.access_keys).to eq(":")
|
21
|
+
end
|
22
|
+
|
23
|
+
describe SmartCoin::SmartCoinObject do
|
24
|
+
it 'should convert to hash' do
|
25
|
+
params_2 = {a: 1, b: 'b'}
|
26
|
+
params = {a: 'a', b: 'b', c: 1, d: SmartCoin::SmartCoinObject.create_from(params_2), e:[a: 'a', b: 1, c: SmartCoin::SmartCoinObject.create_from(params_2)]}
|
27
|
+
obj = SmartCoin::SmartCoinObject.create_from(params)
|
28
|
+
expect(obj.to_hash).to eq(params.merge({d: params_2, e: [a: 'a', b: 1, c: params_2]}))
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should convert to json' do
|
32
|
+
params_2 = {a: 1, b: 'b'}
|
33
|
+
params = {a: 'a', b: 'b', c: 1, d: SmartCoin::SmartCoinObject.create_from(params_2), e:[a: 'a', b: 1, c: SmartCoin::SmartCoinObject.create_from(params_2)]}
|
34
|
+
obj = SmartCoin::SmartCoinObject.create_from(params)
|
35
|
+
expect(obj.to_json).to eq(params.to_json)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should convert to stirng' do
|
39
|
+
params_2 = {a: 1, b: 'b'}
|
40
|
+
params = {a: 'a', b: 'b', c: 1, d: SmartCoin::SmartCoinObject.create_from(params_2), e:[a: 'a', b: 1, c: SmartCoin::SmartCoinObject.create_from(params_2)]}
|
41
|
+
obj = SmartCoin::SmartCoinObject.create_from(params)
|
42
|
+
expect(obj.to_s).to eq(params.to_json.to_s)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative '../rspec_helper'
|
2
|
+
|
3
|
+
describe SmartCoin::Token do
|
4
|
+
|
5
|
+
it 'should call API to create a Token' do
|
6
|
+
SmartCoin.api_key('pk_test_3ac0794848c339')
|
7
|
+
token_params = {number: 4242424242424242,
|
8
|
+
exp_month: 11,
|
9
|
+
exp_year: 2017,
|
10
|
+
cvc: '111',
|
11
|
+
name: 'Arthur Granado'
|
12
|
+
}
|
13
|
+
|
14
|
+
token = SmartCoin::Token.create(token_params)
|
15
|
+
expect(token.id).to match(/tok_(.)/)
|
16
|
+
expect(token.object).to eq('token')
|
17
|
+
expect(token.card.exp_month).to eq(11)
|
18
|
+
expect(token.card.exp_year).to eq(2017)
|
19
|
+
expect(token.card.name).to eq('Arthur Granado')
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: smartcoin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Arthur Granado
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.6.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.6.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.14.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.14.0
|
69
|
+
description: Ruby library to SmartCoin API - https://smartcoin.com.br
|
70
|
+
email:
|
71
|
+
- agranado@smartcoin.com.br
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".ruby-gemset"
|
78
|
+
- ".ruby-version"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- lib/data/shipping-ssl-bundle.crt
|
84
|
+
- lib/data/ssl-bundle.crt
|
85
|
+
- lib/smartcoin.rb
|
86
|
+
- lib/smartcoin/api_operations/create.rb
|
87
|
+
- lib/smartcoin/api_operations/list.rb
|
88
|
+
- lib/smartcoin/api_operations/retrieve.rb
|
89
|
+
- lib/smartcoin/api_operations/update.rb
|
90
|
+
- lib/smartcoin/api_resource.rb
|
91
|
+
- lib/smartcoin/card.rb
|
92
|
+
- lib/smartcoin/charge.rb
|
93
|
+
- lib/smartcoin/errors/smart_coin_error.rb
|
94
|
+
- lib/smartcoin/fee.rb
|
95
|
+
- lib/smartcoin/installment.rb
|
96
|
+
- lib/smartcoin/refund.rb
|
97
|
+
- lib/smartcoin/shipping.rb
|
98
|
+
- lib/smartcoin/smart_coin_object.rb
|
99
|
+
- lib/smartcoin/token.rb
|
100
|
+
- lib/smartcoin/util.rb
|
101
|
+
- lib/smartcoin/version.rb
|
102
|
+
- smartcoin.gemspec
|
103
|
+
- test/rspec_helper.rb
|
104
|
+
- test/smartcoin/api_resource_spec.rb
|
105
|
+
- test/smartcoin/card_spec.rb
|
106
|
+
- test/smartcoin/charge_spec.rb
|
107
|
+
- test/smartcoin/shipping_calculator_spec.rb
|
108
|
+
- test/smartcoin/smart_coin_spec.rb
|
109
|
+
- test/smartcoin/token_spec.rb
|
110
|
+
homepage: https://smartcoin.com.br
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.2.2
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: Ruby bind to SmartCoin API
|
134
|
+
test_files:
|
135
|
+
- test/rspec_helper.rb
|
136
|
+
- test/smartcoin/api_resource_spec.rb
|
137
|
+
- test/smartcoin/card_spec.rb
|
138
|
+
- test/smartcoin/charge_spec.rb
|
139
|
+
- test/smartcoin/shipping_calculator_spec.rb
|
140
|
+
- test/smartcoin/smart_coin_spec.rb
|
141
|
+
- test/smartcoin/token_spec.rb
|