kiik-api 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Manifest +18 -0
- data/README.md +25 -0
- data/Rakefile +29 -0
- data/kiik-api.gemspec +62 -0
- data/lib/kiik-api.rb +58 -0
- data/lib/kiik/cacert.pem +98 -0
- data/lib/kiik/client.rb +79 -0
- data/lib/kiik/errors.rb +38 -0
- data/lib/kiik/logger.rb +21 -0
- data/lib/kiik/response.rb +85 -0
- data/lib/kiik/version.rb +3 -0
- data/lib/kiik/wallet.rb +39 -0
- data/lib/kiik/wallet/client.rb +122 -0
- data/lib/kiik/wallet/creditcard.rb +43 -0
- data/lib/kiik/wallet/transaction.rb +38 -0
- data/lib/kiik/wallet/user.rb +82 -0
- data/spec/fixtures/kiik.yml +6 -0
- data/spec/lib/kiik/wallet_client_spec.rb +55 -0
- data/spec/lib/kiik/wallet_client_user_spec.rb +24 -0
- data/spec/spec_helper.rb +26 -0
- metadata +263 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8e7ffc528b6f4d1485fa33fb1a22f594ee0d94e8
|
4
|
+
data.tar.gz: 1d792e7ae88496a52cb0278eee1328191e892f47
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b2975f6e9d5acecee753f6ccb2a7b87109e04ca4557cf25254298c4376c0342bca9b457617589d0ebaf72d840ac3b532b68689344b64d88fd614ec32012fe3ba
|
7
|
+
data.tar.gz: bc43f2109bffceeaeb26560dc14f3b43f8d0566562dfad4b83165e9ed3d75273d6b2d82a152995ec181c9f6edad99d4b527faabb3951f6608c24fe8580a5abda
|
data/Manifest
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Manifest
|
2
|
+
README.md
|
3
|
+
Rakefile
|
4
|
+
kiik-api.gemspec
|
5
|
+
lib/kiik-api.rb
|
6
|
+
lib/kiik/client.rb
|
7
|
+
lib/kiik/errors.rb
|
8
|
+
lib/kiik/logger.rb
|
9
|
+
lib/kiik/response.rb
|
10
|
+
lib/kiik/version.rb
|
11
|
+
lib/kiik/wallet.rb
|
12
|
+
lib/kiik/wallet/client.rb
|
13
|
+
lib/kiik/wallet/creditcard.rb
|
14
|
+
lib/kiik/wallet/transaction.rb
|
15
|
+
lib/kiik/wallet/user.rb
|
16
|
+
spec/lib/kiik/wallet_client_spec.rb
|
17
|
+
spec/lib/kiik/wallet_client_user_spec.rb
|
18
|
+
spec/spec_helper.rb
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# KiiK - Mobile payments everywhere
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
If this gem actually talked to a service, you could use it in your Ruby
|
6
|
+
project. To do so, you would add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
gem 'kiik-api'
|
9
|
+
|
10
|
+
And then execute:
|
11
|
+
|
12
|
+
$ bundle
|
13
|
+
|
14
|
+
Or install it yourself as:
|
15
|
+
|
16
|
+
$ gem install kiik-api
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
require 'kiik-api'
|
22
|
+
|
23
|
+
```
|
24
|
+
|
25
|
+
Enjoy!
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#!/usr/bin/env rake
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
require 'rspec/core'
|
7
|
+
require 'rspec/core/rake_task'
|
8
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
9
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
13
|
+
spec.pattern = 'specs/**/*_spec.rb'
|
14
|
+
spec.rcov = true
|
15
|
+
end
|
16
|
+
|
17
|
+
task :default => :spec
|
18
|
+
|
19
|
+
require 'rdoc/task'
|
20
|
+
Rake::RDocTask.new do |rdoc|
|
21
|
+
require File.expand_path('../lib/kiik/version', __FILE__)
|
22
|
+
rdoc.rdoc_dir = 'rdoc'
|
23
|
+
rdoc.title = "SanitizeEmail #{Kiik::VERSION}"
|
24
|
+
rdoc.options << '--line-numbers'
|
25
|
+
rdoc.rdoc_files.include('README*')
|
26
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
27
|
+
end
|
28
|
+
|
29
|
+
Bundler::GemHelper.install_tasks
|
data/kiik-api.gemspec
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/kiik/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "kiik-api"
|
6
|
+
s.version = Kiik::VERSION
|
7
|
+
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
|
+
s.authors = ["Bruno de Queiroz"]
|
10
|
+
s.date = "2012-12-24"
|
11
|
+
s.description = "A Gem for Kiik API"
|
12
|
+
s.email = "creativelikeadog@gmail.com"
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split($\)
|
15
|
+
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
|
+
|
18
|
+
s.files = [
|
19
|
+
"Manifest",
|
20
|
+
"README.md",
|
21
|
+
"Rakefile",
|
22
|
+
"kiik-api.gemspec",
|
23
|
+
"lib/kiik-api.rb",
|
24
|
+
"lib/kiik/cacert.pem",
|
25
|
+
"lib/kiik/client.rb",
|
26
|
+
"lib/kiik/errors.rb",
|
27
|
+
"lib/kiik/logger.rb",
|
28
|
+
"lib/kiik/response.rb",
|
29
|
+
"lib/kiik/version.rb",
|
30
|
+
"lib/kiik/wallet.rb",
|
31
|
+
"lib/kiik/wallet/client.rb",
|
32
|
+
"lib/kiik/wallet/creditcard.rb",
|
33
|
+
"lib/kiik/wallet/transaction.rb",
|
34
|
+
"lib/kiik/wallet/user.rb",
|
35
|
+
"spec/lib/kiik/wallet_client_spec.rb",
|
36
|
+
"spec/lib/kiik/wallet_client_user_spec.rb",
|
37
|
+
"spec/spec_helper.rb"
|
38
|
+
|
39
|
+
]
|
40
|
+
s.homepage = "http://github.com/creativelikeadog/kiik-api"
|
41
|
+
s.licenses = ["MIT"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubygems_version = Kiik::VERSION
|
44
|
+
s.summary = "A Gem for Kiik API"
|
45
|
+
|
46
|
+
s.add_dependency "activesupport", "~> 4.1"
|
47
|
+
s.add_dependency "hashie", "~> 3.3"
|
48
|
+
s.add_dependency "faraday", "~> 0.9"
|
49
|
+
s.add_dependency "json", "~> 1.8"
|
50
|
+
s.add_dependency "i18n", "~> 0.7"
|
51
|
+
s.add_dependency "rake", "~> 10.4"
|
52
|
+
s.add_dependency "bundler", "~> 1.0"
|
53
|
+
s.add_dependency "fakeweb", "~> 1.3"
|
54
|
+
s.add_dependency "rspec", "~> 3.0"
|
55
|
+
s.add_dependency "simplecov", "~> 0.9"
|
56
|
+
s.add_dependency "rdoc", "~> 4.0"
|
57
|
+
s.add_dependency "multi_json", "~> 1.3"
|
58
|
+
s.add_dependency "multi_xml", "~> 0.5"
|
59
|
+
s.add_dependency "rack", "~> 1.5"
|
60
|
+
|
61
|
+
end
|
62
|
+
|
data/lib/kiik-api.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'faraday'
|
4
|
+
require 'json'
|
5
|
+
require 'hashie'
|
6
|
+
require 'uri'
|
7
|
+
require "base64"
|
8
|
+
require "openssl"
|
9
|
+
require 'multi_json'
|
10
|
+
require 'multi_xml'
|
11
|
+
require 'rack'
|
12
|
+
|
13
|
+
require 'kiik/errors'
|
14
|
+
require 'kiik/logger'
|
15
|
+
require 'kiik/client'
|
16
|
+
require 'kiik/response'
|
17
|
+
require 'kiik/wallet'
|
18
|
+
require 'kiik/wallet/client'
|
19
|
+
require 'kiik/wallet/user'
|
20
|
+
require 'kiik/wallet/creditcard'
|
21
|
+
require 'kiik/wallet/transaction'
|
22
|
+
|
23
|
+
module Kiik
|
24
|
+
# set a default
|
25
|
+
|
26
|
+
class << self
|
27
|
+
attr_accessor :config_path
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.config
|
31
|
+
@config ||= load_config
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.wallet
|
35
|
+
@wallet ||= Kiik::Wallet.new(config[:token],config[:wallet])
|
36
|
+
@wallet.api
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.load_config
|
40
|
+
|
41
|
+
if @config_path.nil?
|
42
|
+
if defined?(Rails)
|
43
|
+
@config_path = Rails.root.join('config','kiik.yml')
|
44
|
+
else
|
45
|
+
@config_path = 'kiik.yml'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
unless File.file?(config_path)
|
50
|
+
raise NotConfigured.new("The #{config_path} config file is missing.")
|
51
|
+
end
|
52
|
+
|
53
|
+
cfg = YAML.load_file(config_path)
|
54
|
+
raise NoAuthorizationTokenProvided.new("You will need a authorization token to perform request on kiik api") if cfg[:token].nil?
|
55
|
+
cfg
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
data/lib/kiik/cacert.pem
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIE0DCCA7igAwIBAgIQMX4VqpV4+B1CYUZ+nMXuwjANBgkqhkiG9w0BAQUFADA8
|
3
|
+
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMVGhhd3RlLCBJbmMuMRYwFAYDVQQDEw1U
|
4
|
+
aGF3dGUgU1NMIENBMB4XDTE0MDgyMTAwMDAwMFoXDTE1MTAyMDIzNTk1OVowgaEx
|
5
|
+
CzAJBgNVBAYTAkJSMRIwEAYDVQQIEwlTYW8gUGF1bG8xEjAQBgNVBAcUCVNhbyBQ
|
6
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j/xw0llmozFyD4lt5SZu5IycQfwhl7tUCemDaYj+bvLpgcUQg==
|
98
|
+
-----END CERTIFICATE-----
|
data/lib/kiik/client.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
module Kiik
|
2
|
+
|
3
|
+
class Client
|
4
|
+
|
5
|
+
attr_reader :site
|
6
|
+
attr_accessor :token, :options
|
7
|
+
|
8
|
+
def initialize(token, options={}, &block)
|
9
|
+
opts = options.dup
|
10
|
+
@token = token
|
11
|
+
@site = opts.delete(:site)
|
12
|
+
ssl = opts.delete(:ssl)
|
13
|
+
@options = {:connection_opts => {},
|
14
|
+
:connection_build => block,
|
15
|
+
:max_redirects => 5,
|
16
|
+
:raise_errors => true}.merge(opts)
|
17
|
+
@options[:connection_opts][:ssl] = ssl if ssl
|
18
|
+
end
|
19
|
+
|
20
|
+
def site=(value)
|
21
|
+
@connection = nil
|
22
|
+
@site = value
|
23
|
+
end
|
24
|
+
|
25
|
+
# The Faraday connection object
|
26
|
+
def connection
|
27
|
+
@connection ||= begin
|
28
|
+
conn = Faraday.new(site, options[:connection_opts])
|
29
|
+
conn.build do |b|
|
30
|
+
options[:connection_build].call(b)
|
31
|
+
end if options[:connection_build]
|
32
|
+
conn
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def authorization_header(params = {})
|
37
|
+
params.merge({ 'Authorization' => "Token token=#{token}" })
|
38
|
+
end
|
39
|
+
|
40
|
+
def request(verb, url, opts = {})
|
41
|
+
connection.response :logger, ::Logger.new($stdout) if ENV['OAUTH_DEBUG'] == 'true'
|
42
|
+
|
43
|
+
url = connection.build_url(url, opts[:params]).to_s
|
44
|
+
|
45
|
+
Kiik::Logger.info(url)
|
46
|
+
|
47
|
+
response = connection.run_request(verb, url, opts[:body], authorization_header(opts[:headers])) do |req|
|
48
|
+
yield(req) if block_given?
|
49
|
+
end
|
50
|
+
response = Response.new(response, :parse => opts[:parse])
|
51
|
+
|
52
|
+
case response.status
|
53
|
+
when 301, 302, 303, 307
|
54
|
+
opts[:redirect_count] ||= 0
|
55
|
+
opts[:redirect_count] += 1
|
56
|
+
return response if opts[:redirect_count] > options[:max_redirects]
|
57
|
+
if response.status == 303
|
58
|
+
verb = :get
|
59
|
+
opts.delete(:body)
|
60
|
+
end
|
61
|
+
request(verb, response.headers['location'], opts)
|
62
|
+
when 200..299, 300..399
|
63
|
+
# on non-redirecting 3xx statuses, just return the response
|
64
|
+
response
|
65
|
+
when 400..599
|
66
|
+
error = Error.new(response)
|
67
|
+
fail(error) if opts.fetch(:raise_errors, options[:raise_errors])
|
68
|
+
response.error = error
|
69
|
+
response
|
70
|
+
else
|
71
|
+
error = Error.new(response)
|
72
|
+
fail(error, "Unhandled status code value of #{response.status}")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
data/lib/kiik/errors.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Kiik
|
2
|
+
|
3
|
+
class NotConfigured < Exception
|
4
|
+
end
|
5
|
+
|
6
|
+
class NoAuthorizationTokenProvided < Exception
|
7
|
+
end
|
8
|
+
|
9
|
+
class TypeNotSupported < Exception
|
10
|
+
end
|
11
|
+
|
12
|
+
class MethodNotAllowedForType < Exception
|
13
|
+
end
|
14
|
+
|
15
|
+
class Error < StandardError
|
16
|
+
attr_reader :response, :code, :description
|
17
|
+
|
18
|
+
# standard error values include:
|
19
|
+
# :invalid_request, :invalid_client, :invalid_token, :invalid_grant, :unsupported_grant_type, :invalid_scope
|
20
|
+
def initialize(response)
|
21
|
+
response.error = self
|
22
|
+
@response = response
|
23
|
+
|
24
|
+
message = []
|
25
|
+
|
26
|
+
if response.parsed.is_a?(Hash)
|
27
|
+
@code = response.parsed['error']
|
28
|
+
@description = response.parsed['error_description']
|
29
|
+
message << "#{@code}: #{@description}"
|
30
|
+
end
|
31
|
+
|
32
|
+
message << response.body
|
33
|
+
|
34
|
+
super(message.join("\n"))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/lib/kiik/logger.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Kiik
|
2
|
+
class Logger
|
3
|
+
def self.info(msg)
|
4
|
+
puts "Kiik::INFO: #{msg}"
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.warn(msg)
|
8
|
+
puts "Kiik::WARN: #{msg}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.error(msg)
|
12
|
+
puts "Kiik::ERROR: #{msg}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.inspect(msg)
|
16
|
+
puts "Kiik::INSPECT:"
|
17
|
+
p msg
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Kiik
|
2
|
+
# OAuth2::Response class
|
3
|
+
class Response
|
4
|
+
attr_reader :response
|
5
|
+
attr_accessor :error, :options
|
6
|
+
|
7
|
+
# Adds a new content type parser.
|
8
|
+
#
|
9
|
+
# @param [Symbol] key A descriptive symbol key such as :json or :query.
|
10
|
+
# @param [Array] One or more mime types to which this parser applies.
|
11
|
+
# @yield [String] A block returning parsed content.
|
12
|
+
def self.register_parser(key, mime_types, &block)
|
13
|
+
key = key.to_sym
|
14
|
+
PARSERS[key] = block
|
15
|
+
Array(mime_types).each do |mime_type|
|
16
|
+
CONTENT_TYPES[mime_type] = key
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Initializes a Response instance
|
21
|
+
#
|
22
|
+
# @param [Faraday::Response] response The Faraday response instance
|
23
|
+
# @param [Hash] opts options in which to initialize the instance
|
24
|
+
# @option opts [Symbol] :parse (:automatic) how to parse the response body. one of :query (for x-www-form-urlencoded),
|
25
|
+
# :json, or :automatic (determined by Content-Type response header)
|
26
|
+
def initialize(response, opts = {})
|
27
|
+
@response = response
|
28
|
+
@options = {:parse => :automatic}.merge(opts)
|
29
|
+
end
|
30
|
+
|
31
|
+
# The HTTP response headers
|
32
|
+
def headers
|
33
|
+
response.headers
|
34
|
+
end
|
35
|
+
|
36
|
+
# The HTTP response status code
|
37
|
+
def status
|
38
|
+
response.status
|
39
|
+
end
|
40
|
+
|
41
|
+
# The HTTP response body
|
42
|
+
def body
|
43
|
+
response.body || ''
|
44
|
+
end
|
45
|
+
|
46
|
+
# Procs that, when called, will parse a response body according
|
47
|
+
# to the specified format.
|
48
|
+
PARSERS = {
|
49
|
+
:json => lambda { |body| MultiJson.load(body) rescue body }, # rubocop:disable RescueModifier
|
50
|
+
:query => lambda { |body| Rack::Utils.parse_query(body) },
|
51
|
+
:text => lambda { |body| body },
|
52
|
+
}
|
53
|
+
|
54
|
+
# Content type assignments for various potential HTTP content types.
|
55
|
+
CONTENT_TYPES = {
|
56
|
+
'application/json' => :json,
|
57
|
+
'text/javascript' => :json,
|
58
|
+
'application/x-www-form-urlencoded' => :query,
|
59
|
+
'text/plain' => :text,
|
60
|
+
}
|
61
|
+
|
62
|
+
# The parsed response body.
|
63
|
+
# Will attempt to parse application/x-www-form-urlencoded and
|
64
|
+
# application/json Content-Type response bodies
|
65
|
+
def parsed
|
66
|
+
return nil unless PARSERS.key?(parser)
|
67
|
+
@parsed ||= PARSERS[parser].call(body)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Attempts to determine the content type of the response.
|
71
|
+
def content_type
|
72
|
+
((response.headers.values_at('content-type', 'Content-Type').compact.first || '').split(';').first || '').strip
|
73
|
+
end
|
74
|
+
|
75
|
+
# Determines the parser that will be used to supply the content of #parsed
|
76
|
+
def parser
|
77
|
+
return options[:parse].to_sym if PARSERS.key?(options[:parse])
|
78
|
+
CONTENT_TYPES[content_type]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
Kiik::Response.register_parser(:xml, ['text/xml', 'application/rss+xml', 'application/rdf+xml', 'application/atom+xml']) do |body|
|
84
|
+
MultiXml.parse(body) rescue body # rubocop:disable RescueModifier
|
85
|
+
end
|
data/lib/kiik/version.rb
ADDED
data/lib/kiik/wallet.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module Kiik
|
2
|
+
|
3
|
+
class Wallet
|
4
|
+
attr_reader :token, :site, :version
|
5
|
+
attr_accessor :logger, :options
|
6
|
+
|
7
|
+
def initialize(token,options={})
|
8
|
+
@site = 'https://wallet.kiik.com.br'
|
9
|
+
@version = 'v1'
|
10
|
+
@token = token
|
11
|
+
@ca_file = options.delete(:ca_file) || default_ca_file
|
12
|
+
@logger = options.delete(:logger) || Kiik::Logger
|
13
|
+
@options = options
|
14
|
+
return true
|
15
|
+
end
|
16
|
+
|
17
|
+
def client
|
18
|
+
@client ||= Kiik::Client.new(token,:site => { :url => site },:ssl => client_ssl_options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def api
|
22
|
+
@api ||= Kiik::Wallet::Client.new(self,options)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def rest_client_ssl_options
|
27
|
+
{ :ssl_ca_file => @ca_file, :verify_ssl => OpenSSL::SSL::VERIFY_PEER }
|
28
|
+
end
|
29
|
+
|
30
|
+
def client_ssl_options
|
31
|
+
{ :ca_file => @ca_file, :verify => OpenSSL::SSL::VERIFY_PEER }
|
32
|
+
end
|
33
|
+
|
34
|
+
def default_ca_file
|
35
|
+
File.join(File.dirname(__FILE__), 'cacert.pem')
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
module Kiik
|
2
|
+
class Wallet
|
3
|
+
class Client
|
4
|
+
|
5
|
+
ALLOWED_TYPES = {
|
6
|
+
:client => [ :create, :detail ],
|
7
|
+
:user => [ :create ],
|
8
|
+
:creditcard => [ :create, :detail ],
|
9
|
+
:transaction => [ :create ]
|
10
|
+
}
|
11
|
+
|
12
|
+
attr_reader :name, :id, :secret, :access_token, :email
|
13
|
+
|
14
|
+
def initialize(wallet,options)
|
15
|
+
@id = options[:api_id]
|
16
|
+
@name = options[:name]
|
17
|
+
@email = options[:email]
|
18
|
+
@secret = options[:api_secret]
|
19
|
+
@access_token = options[:access_token]
|
20
|
+
@wallet = wallet
|
21
|
+
@base_uri = '/clients/#{id}'
|
22
|
+
end
|
23
|
+
|
24
|
+
def token
|
25
|
+
@wallet.token
|
26
|
+
end
|
27
|
+
|
28
|
+
def client
|
29
|
+
@wallet.client
|
30
|
+
end
|
31
|
+
|
32
|
+
def use_token(new_token,&block)
|
33
|
+
@wallet.client.token = new_token
|
34
|
+
block.call(self)
|
35
|
+
@wallet.client.token = @wallet.token
|
36
|
+
end
|
37
|
+
|
38
|
+
def detail(type,options={},&block)
|
39
|
+
allow(type,:detail)
|
40
|
+
|
41
|
+
case type
|
42
|
+
when :client
|
43
|
+
request(:get, base_uri,{}, &block)
|
44
|
+
when :creditcard
|
45
|
+
token = options.delete(:token)
|
46
|
+
card.detail(token,options,&block)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
def list(type,options={},&block)
|
52
|
+
allow(type,:list)
|
53
|
+
|
54
|
+
case type
|
55
|
+
when :creditcard
|
56
|
+
token = options.delete(:token)
|
57
|
+
card.list(token,&block)
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
def set_secret(secret,&block)
|
63
|
+
request(:put, base_uri, { :client => { :api_secret => secret } },&block)
|
64
|
+
end
|
65
|
+
|
66
|
+
def create(type, options={},&block)
|
67
|
+
allow(type,:create)
|
68
|
+
|
69
|
+
token = options.delete(:token)
|
70
|
+
case type
|
71
|
+
when :user
|
72
|
+
user.create(options,&block)
|
73
|
+
when :creditcard
|
74
|
+
card.create(token,options,&block)
|
75
|
+
when :transaction
|
76
|
+
transaction.create(token,options.delete(:credit_card),options,&block)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def user
|
81
|
+
@user ||= Kiik::Wallet::User.new(self)
|
82
|
+
end
|
83
|
+
|
84
|
+
def card
|
85
|
+
@card ||= Kiik::Wallet::Creditcard.new(self)
|
86
|
+
end
|
87
|
+
|
88
|
+
def transaction
|
89
|
+
@transaction ||= Kiik::Wallet::Transaction.new(self)
|
90
|
+
end
|
91
|
+
|
92
|
+
def request(verb, uri, params = {}, &block)
|
93
|
+
response = @wallet.client.request(verb, "/#{@wallet.version}#{uri}", request_params(params))
|
94
|
+
|
95
|
+
if block_given?
|
96
|
+
yield(response.parsed)
|
97
|
+
else
|
98
|
+
response.parsed
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
def allow(type,method)
|
104
|
+
raise TypeNotSupported.new("The #{type} is not supported by this api") if !ALLOWED_TYPES.include?(type)
|
105
|
+
raise MethodNotAllowedForType.new("This type: #{type} don't allow this method.") if !ALLOWED_TYPES[type].include?(method)
|
106
|
+
end
|
107
|
+
|
108
|
+
def request_params(params={})
|
109
|
+
p = {
|
110
|
+
:params => {},
|
111
|
+
:body => params.to_json,
|
112
|
+
:headers => {
|
113
|
+
'Accept' => 'application/json',
|
114
|
+
'Content-type' => 'application/json'
|
115
|
+
}
|
116
|
+
}
|
117
|
+
p
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Kiik
|
2
|
+
class Wallet
|
3
|
+
class Creditcard
|
4
|
+
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
@base_uri = '/cards'
|
8
|
+
end
|
9
|
+
|
10
|
+
def create(token,options={},&block)
|
11
|
+
params = {
|
12
|
+
:card => {
|
13
|
+
:name => options[:name],
|
14
|
+
:number => options[:number],
|
15
|
+
:expiration_month => options[:expiration_month],
|
16
|
+
:expiration_year => options[:expiration_year]
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
request(token,:post,@base_uri,params,&block)
|
21
|
+
end
|
22
|
+
|
23
|
+
def list(token,&block)
|
24
|
+
request(token,:get,@base_uri,{},&block)
|
25
|
+
end
|
26
|
+
|
27
|
+
def get(token,id,&block)
|
28
|
+
request(token,:get,"#{@base_uri}/#{id}",{},&block)
|
29
|
+
end
|
30
|
+
|
31
|
+
def detail(token,id,&block)
|
32
|
+
request(token,:get,"#{@base_uri}/#{id}/details",{},&block)
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
def request(token,verb,url,params,&block)
|
37
|
+
proc = Proc.new { |client| client.request(verb,url,params,&block) }
|
38
|
+
@client.use_token(token, &proc)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Kiik
|
2
|
+
class Wallet
|
3
|
+
class Transaction
|
4
|
+
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
@base_uri = '/transactions/card'
|
8
|
+
end
|
9
|
+
|
10
|
+
def create(token,card,options={},&block)
|
11
|
+
params = {
|
12
|
+
:card => {
|
13
|
+
:credit_card_token => card[:token],
|
14
|
+
:cvv => card[:cvv]
|
15
|
+
},
|
16
|
+
:transaction => {
|
17
|
+
:recipient => options[:recipient],
|
18
|
+
:amount => options[:amount],
|
19
|
+
:order_number => options[:order_number]
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
request(token,:post,@base_uri,params,&block)
|
24
|
+
end
|
25
|
+
|
26
|
+
def callback(token,params={},&block)
|
27
|
+
request(token,:put,'/payment/callback',params,&block)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
def request(token,verb,url,params,&block)
|
32
|
+
proc = Proc.new { |client| client.request(verb,url,params,&block) }
|
33
|
+
@client.use_token(token, &proc)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module Kiik
|
2
|
+
class Wallet
|
3
|
+
class User
|
4
|
+
|
5
|
+
attr_reader :token
|
6
|
+
|
7
|
+
def initialize(client)
|
8
|
+
@client = client
|
9
|
+
@base_uri = '/users'
|
10
|
+
@card = Kiik::Wallet::Creditcard.new(client)
|
11
|
+
end
|
12
|
+
|
13
|
+
def create(options={},&block)
|
14
|
+
params = {
|
15
|
+
:user => {
|
16
|
+
:email => options[:email],
|
17
|
+
:password => options[:password],
|
18
|
+
:external_id => options[:id]
|
19
|
+
}
|
20
|
+
}
|
21
|
+
@client.request(:post,@base_uri,request_params(params),&block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def update(options={},&block)
|
25
|
+
params = {
|
26
|
+
:user => {
|
27
|
+
:email => options[:email],
|
28
|
+
:password => options[:password],
|
29
|
+
:new_password => options[:new_password]
|
30
|
+
}
|
31
|
+
}
|
32
|
+
@client.request(:put,"#{@base_uri}/#{options[:id]}",request_params(params),&block)
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_password(options={},&block)
|
36
|
+
params = {
|
37
|
+
:user => {
|
38
|
+
:email => options[:email],
|
39
|
+
:password => options[:password],
|
40
|
+
:new_password => options[:new_password]
|
41
|
+
}
|
42
|
+
}
|
43
|
+
@client.request(:put,"#{@base_uri}/#{options[:id]}",request_params(params),&block)
|
44
|
+
end
|
45
|
+
|
46
|
+
def login(options={},&block)
|
47
|
+
params = {
|
48
|
+
:auth => {
|
49
|
+
:external_id => options[:id],
|
50
|
+
:password => options[:password]
|
51
|
+
}
|
52
|
+
}
|
53
|
+
@client.request(:post, '/auth/login', params ) do |response|
|
54
|
+
@token = response["token"]
|
55
|
+
block.call(response)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def regenerate_token(options={},&block)
|
60
|
+
params = {
|
61
|
+
:auth => {
|
62
|
+
:external_id => options[:id],
|
63
|
+
:password => options[:password]
|
64
|
+
}
|
65
|
+
}
|
66
|
+
@client.request(:post, '/auth/regenerate_token', params ) do |response|
|
67
|
+
@token = response["token"]
|
68
|
+
block.call(response)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def create_creditcard(options={},&block)
|
73
|
+
@card.create(options,&block)
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
def request_params(params={})
|
78
|
+
params.merge({ :client => { :api_id => @client.id } })
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Kiik do
|
4
|
+
|
5
|
+
|
6
|
+
context 'initialization' do
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
Kiik.config_path = 'spec/fixtures/kiik.yml'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should set the token' do
|
13
|
+
expect(Kiik.config[:token]).to eq("098f6bcd4621d373cade4e832627b4f6")
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should set the wallet object' do
|
17
|
+
expect(Kiik.config[:wallet]).not_to be_empty
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
describe Kiik::Wallet do
|
23
|
+
|
24
|
+
context "initialization" do
|
25
|
+
let(:wallet) { Kiik.wallet }
|
26
|
+
|
27
|
+
it 'should set the token' do
|
28
|
+
expect(wallet.token).to eq("098f6bcd4621d373cade4e832627b4f6")
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should set the app_id' do
|
32
|
+
expect(wallet.id).to eq("WALT")
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should set the app_secret' do
|
36
|
+
expect(wallet.secret).to eq("b5i32od62d5hadxvopcgsdmipv2g8b")
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should use token in header' do
|
40
|
+
proc = Proc.new { |wallet| expect(wallet.client.authorization_header({})['Authorization']).to eq('Token token=abcde') }
|
41
|
+
wallet.use_token('abcde',&proc)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should use default token' do
|
45
|
+
expect(wallet.client.authorization_header({})['Authorization']).to eq('Token token=098f6bcd4621d373cade4e832627b4f6')
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Kiik do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
Kiik.config_path = 'spec/fixtures/kiik.yml'
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Kiik::Wallet::Client do
|
10
|
+
|
11
|
+
let(:wallet) { Kiik.wallet }
|
12
|
+
|
13
|
+
context "initialization" do
|
14
|
+
|
15
|
+
it 'should set the user api ' do
|
16
|
+
expect(wallet.user).not_to be_nil
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
|
8
|
+
require 'kiik-api'
|
9
|
+
begin
|
10
|
+
require 'redgreen'
|
11
|
+
rescue LoadError
|
12
|
+
# redgreen is for pretty spec result colors on Windows... no biggie.
|
13
|
+
end
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.run_all_when_everything_filtered = true
|
17
|
+
config.filter_run :focus
|
18
|
+
|
19
|
+
# Run specs in random order to surface order dependencies. If you find an
|
20
|
+
# order dependency and want to debug it, you can fix the order by providing
|
21
|
+
# the seed, which is printed after each run.
|
22
|
+
# --seed 1234
|
23
|
+
config.order = 'random'
|
24
|
+
end
|
25
|
+
|
26
|
+
|
metadata
ADDED
@@ -0,0 +1,263 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kiik-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bruno de Queiroz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2012-12-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hashie
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.9'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.8'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: i18n
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.7'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.7'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.4'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.4'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bundler
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: fakeweb
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.3'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.3'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '3.0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '3.0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simplecov
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.9'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.9'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rdoc
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '4.0'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '4.0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: multi_json
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '1.3'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '1.3'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: multi_xml
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0.5'
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0.5'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: rack
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '1.5'
|
202
|
+
type: :runtime
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '1.5'
|
209
|
+
description: A Gem for Kiik API
|
210
|
+
email: creativelikeadog@gmail.com
|
211
|
+
executables: []
|
212
|
+
extensions: []
|
213
|
+
extra_rdoc_files: []
|
214
|
+
files:
|
215
|
+
- Manifest
|
216
|
+
- README.md
|
217
|
+
- Rakefile
|
218
|
+
- kiik-api.gemspec
|
219
|
+
- lib/kiik-api.rb
|
220
|
+
- lib/kiik/cacert.pem
|
221
|
+
- lib/kiik/client.rb
|
222
|
+
- lib/kiik/errors.rb
|
223
|
+
- lib/kiik/logger.rb
|
224
|
+
- lib/kiik/response.rb
|
225
|
+
- lib/kiik/version.rb
|
226
|
+
- lib/kiik/wallet.rb
|
227
|
+
- lib/kiik/wallet/client.rb
|
228
|
+
- lib/kiik/wallet/creditcard.rb
|
229
|
+
- lib/kiik/wallet/transaction.rb
|
230
|
+
- lib/kiik/wallet/user.rb
|
231
|
+
- spec/fixtures/kiik.yml
|
232
|
+
- spec/lib/kiik/wallet_client_spec.rb
|
233
|
+
- spec/lib/kiik/wallet_client_user_spec.rb
|
234
|
+
- spec/spec_helper.rb
|
235
|
+
homepage: http://github.com/creativelikeadog/kiik-api
|
236
|
+
licenses:
|
237
|
+
- MIT
|
238
|
+
metadata: {}
|
239
|
+
post_install_message:
|
240
|
+
rdoc_options: []
|
241
|
+
require_paths:
|
242
|
+
- lib
|
243
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
244
|
+
requirements:
|
245
|
+
- - ">="
|
246
|
+
- !ruby/object:Gem::Version
|
247
|
+
version: '0'
|
248
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
249
|
+
requirements:
|
250
|
+
- - ">="
|
251
|
+
- !ruby/object:Gem::Version
|
252
|
+
version: '0'
|
253
|
+
requirements: []
|
254
|
+
rubyforge_project:
|
255
|
+
rubygems_version: 2.2.2
|
256
|
+
signing_key:
|
257
|
+
specification_version: 4
|
258
|
+
summary: A Gem for Kiik API
|
259
|
+
test_files:
|
260
|
+
- spec/fixtures/kiik.yml
|
261
|
+
- spec/lib/kiik/wallet_client_spec.rb
|
262
|
+
- spec/lib/kiik/wallet_client_user_spec.rb
|
263
|
+
- spec/spec_helper.rb
|