espago 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +67 -0
- data/Guardfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +28 -0
- data/Rakefile +6 -0
- data/espago.gemspec +30 -0
- data/lib/espago.rb +27 -0
- data/lib/espago/api_connection.rb +54 -0
- data/lib/espago/api_connection/delete_charges.rb +13 -0
- data/lib/espago/api_connection/delete_clients.rb +13 -0
- data/lib/espago/api_connection/get_charges.rb +17 -0
- data/lib/espago/api_connection/get_clients.rb +17 -0
- data/lib/espago/api_connection/get_tokens.rb +13 -0
- data/lib/espago/api_connection/post_charges.rb +13 -0
- data/lib/espago/api_connection/post_charges_refund.rb +13 -0
- data/lib/espago/api_connection/post_clients.rb +13 -0
- data/lib/espago/api_connection/post_clients_authorize.rb +13 -0
- data/lib/espago/api_connection/post_complete.rb +13 -0
- data/lib/espago/api_connection/post_tokens.rb +14 -0
- data/lib/espago/api_connection/put_clients.rb +13 -0
- data/lib/espago/client.rb +34 -0
- data/lib/espago/response.rb +55 -0
- data/lib/espago/router.rb +33 -0
- data/lib/espago/version.rb +3 -0
- data/spec/espago/api_connection_spec.rb +23 -0
- data/spec/espago/client_spec.rb +52 -0
- data/spec/espago/response_spec.rb +36 -0
- data/spec/espago/router_spec.rb +36 -0
- data/spec/spec_helper.rb +17 -0
- metadata +232 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
espago (0.0.6)
|
5
|
+
facets
|
6
|
+
faraday
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
coderay (1.0.8)
|
12
|
+
diff-lcs (1.1.3)
|
13
|
+
facets (2.9.3)
|
14
|
+
faraday (0.8.7)
|
15
|
+
multipart-post (~> 1.1)
|
16
|
+
fuubar (1.1.0)
|
17
|
+
rspec (~> 2.0)
|
18
|
+
rspec-instafail (~> 0.2.0)
|
19
|
+
ruby-progressbar (~> 1.0.0)
|
20
|
+
guard (1.6.1)
|
21
|
+
listen (>= 0.6.0)
|
22
|
+
lumberjack (>= 1.0.2)
|
23
|
+
pry (>= 0.9.10)
|
24
|
+
thor (>= 0.14.6)
|
25
|
+
guard-rspec (2.3.3)
|
26
|
+
guard (>= 1.1)
|
27
|
+
rspec (~> 2.11)
|
28
|
+
listen (0.7.2)
|
29
|
+
lumberjack (1.0.2)
|
30
|
+
method_source (0.8.1)
|
31
|
+
multi_json (1.5.0)
|
32
|
+
multipart-post (1.2.0)
|
33
|
+
pry (0.9.10)
|
34
|
+
coderay (~> 1.0.5)
|
35
|
+
method_source (~> 0.8)
|
36
|
+
slop (~> 3.3.1)
|
37
|
+
rake (10.0.2)
|
38
|
+
rb-fsevent (0.9.3)
|
39
|
+
rspec (2.12.0)
|
40
|
+
rspec-core (~> 2.12.0)
|
41
|
+
rspec-expectations (~> 2.12.0)
|
42
|
+
rspec-mocks (~> 2.12.0)
|
43
|
+
rspec-core (2.12.2)
|
44
|
+
rspec-expectations (2.12.1)
|
45
|
+
diff-lcs (~> 1.1.3)
|
46
|
+
rspec-instafail (0.2.4)
|
47
|
+
rspec-mocks (2.12.1)
|
48
|
+
ruby-progressbar (1.0.2)
|
49
|
+
simplecov (0.7.1)
|
50
|
+
multi_json (~> 1.0)
|
51
|
+
simplecov-html (~> 0.7.1)
|
52
|
+
simplecov-html (0.7.1)
|
53
|
+
slop (3.3.3)
|
54
|
+
thor (0.16.0)
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
ruby
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
espago!
|
61
|
+
fuubar
|
62
|
+
guard-rspec
|
63
|
+
pry
|
64
|
+
rake
|
65
|
+
rb-fsevent (~> 0.9.1)
|
66
|
+
rspec
|
67
|
+
simplecov
|
data/Guardfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec' do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
7
|
+
watch(%r{^lib/espago/(.+)\.rb$}) { |m| "spec/espago/#{m[1]}_spec.rb" }
|
8
|
+
watch('spec/spec_helper.rb') { "spec" }
|
9
|
+
end
|
10
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Piotrek
|
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,28 @@
|
|
1
|
+
Espago gem
|
2
|
+
======
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/espago/espago.png?branch=master)](https://travis-ci.org/espago/espago)
|
5
|
+
|
6
|
+
### Installing Espago gem
|
7
|
+
|
8
|
+
gem install espago
|
9
|
+
|
10
|
+
or just add it to your Gemfile if you are running a Rails project
|
11
|
+
|
12
|
+
## Configuration
|
13
|
+
|
14
|
+
After registering at <http://espago.com> configure your app with the security credentials.
|
15
|
+
|
16
|
+
### Global
|
17
|
+
|
18
|
+
The most standard way of configuring Espago is to do it globally on the Espago class.
|
19
|
+
|
20
|
+
Espago.app_id = 'your-espago-app-id'
|
21
|
+
Espago.app_password = 'your-espago-secret'
|
22
|
+
Espago.public_key = 'your-espago-key'
|
23
|
+
Espago.production = false #sets Espago enviroment to sandbox
|
24
|
+
|
25
|
+
### Sending request
|
26
|
+
|
27
|
+
response = Espago.send_request(:clients, :get)
|
28
|
+
response = Espago.clients :get
|
data/Rakefile
ADDED
data/espago.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'espago/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "espago"
|
8
|
+
gem.version = Espago::VERSION
|
9
|
+
gem.authors = ["Piotrek"]
|
10
|
+
gem.email = ["pkurek90@gmail.com"]
|
11
|
+
gem.description = %q{Espago api wrapper}
|
12
|
+
gem.summary = %q{Espago api wrapper}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency "faraday"
|
21
|
+
gem.add_dependency "facets"
|
22
|
+
|
23
|
+
gem.add_development_dependency "rspec"
|
24
|
+
gem.add_development_dependency "pry"
|
25
|
+
gem.add_development_dependency "guard-rspec"
|
26
|
+
gem.add_development_dependency "simplecov"
|
27
|
+
gem.add_development_dependency "fuubar"
|
28
|
+
gem.add_development_dependency 'rake'
|
29
|
+
gem.add_development_dependency 'rb-fsevent', '~> 0.9.1'
|
30
|
+
end
|
data/lib/espago.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "espago/version"
|
2
|
+
require "espago/client"
|
3
|
+
require "espago/router"
|
4
|
+
require 'forwardable'
|
5
|
+
|
6
|
+
module Espago
|
7
|
+
|
8
|
+
class << self
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
def_delegators :default_client, :public_key, :app_id, :app_password, :send_request, :production
|
12
|
+
def_delegators :default_client, :public_key= , :app_id= , :app_password=, :production=
|
13
|
+
|
14
|
+
def method_missing(method, *args, &block)
|
15
|
+
if Router.new(method, args[0]).path_exists?
|
16
|
+
@default_client.send_request(method, args[0], args[1] || {} )
|
17
|
+
else
|
18
|
+
super
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def default_client
|
24
|
+
@default_client ||= Espago::Client.new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "json"
|
3
|
+
require "forwardable"
|
4
|
+
require "espago/router"
|
5
|
+
require "facets/kernel/require_all"
|
6
|
+
|
7
|
+
require_all "api_connection/*"
|
8
|
+
|
9
|
+
module Espago
|
10
|
+
class ApiConnection
|
11
|
+
extend Forwardable
|
12
|
+
def_delegator :@connection, :basic_auth, :authenticate
|
13
|
+
|
14
|
+
Error = Class.new(StandardError)
|
15
|
+
AuthenticationError = Class.new(StandardError)
|
16
|
+
|
17
|
+
def initialize(enviroment)
|
18
|
+
@connection = Faraday.new(enviroment)
|
19
|
+
@router = Router
|
20
|
+
end
|
21
|
+
|
22
|
+
def create(path, method, params = {} )
|
23
|
+
route = @router.new(path, method).route
|
24
|
+
response = route.new(@connection).request(params)
|
25
|
+
|
26
|
+
handle_response response
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def handle_response(response)
|
32
|
+
case response.status
|
33
|
+
when 200
|
34
|
+
return parse(response.body)
|
35
|
+
when 202
|
36
|
+
return true
|
37
|
+
when 400
|
38
|
+
raise Error, { error_message: 'bad request', status: 400 }
|
39
|
+
when 401
|
40
|
+
raise AuthenticationError, { error_message: 'not authenticated', status: 401 }
|
41
|
+
when 404
|
42
|
+
raise Error, { error_message: 'not found', status: 404 }
|
43
|
+
when 407
|
44
|
+
raise Error, { error_message: 'proxy authentication required', status: 407 }
|
45
|
+
else
|
46
|
+
raise Error, { error_message: 'unknown error', status: response.status }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def parse(body)
|
51
|
+
JSON.parse body
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Espago
|
2
|
+
class ApiConnection
|
3
|
+
class GetCharges
|
4
|
+
def initialize(connection)
|
5
|
+
@connection = connection
|
6
|
+
end
|
7
|
+
|
8
|
+
def request(params = {})
|
9
|
+
if params[:charge_id]
|
10
|
+
@connection.get "charges/#{params[:charge_id]}"
|
11
|
+
else
|
12
|
+
@connection.get "charges", params
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Espago
|
2
|
+
class ApiConnection
|
3
|
+
class GetClients
|
4
|
+
def initialize(connection)
|
5
|
+
@connection = connection
|
6
|
+
end
|
7
|
+
|
8
|
+
def request(params = {})
|
9
|
+
if params[:client_id]
|
10
|
+
@connection.get "clients/#{params[:client_id]}"
|
11
|
+
else
|
12
|
+
@connection.get "clients", params
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Espago
|
2
|
+
class ApiConnection
|
3
|
+
class PostTokens
|
4
|
+
def initialize(connection)
|
5
|
+
@connection = connection
|
6
|
+
@connection.basic_auth(Espago.public_key, '')
|
7
|
+
end
|
8
|
+
|
9
|
+
def request(params = {})
|
10
|
+
@connection.post "tokens", params
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "espago/api_connection"
|
2
|
+
require "espago/response"
|
3
|
+
|
4
|
+
module Espago
|
5
|
+
class Client
|
6
|
+
attr_accessor :public_key, :app_id, :app_password, :production
|
7
|
+
NotAuthenticated = Class.new(StandardError)
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@public_key, @app_id, @app_password = options.values_at( :public_key, :app_id, :app_password)
|
11
|
+
@connection = options[:connection] || ApiConnection
|
12
|
+
end
|
13
|
+
|
14
|
+
def send_request(path, method, params = {})
|
15
|
+
raise NotAuthenticated unless valid?
|
16
|
+
connection = @connection.new(enviroment)
|
17
|
+
connection.authenticate(@app_id, @app_password)
|
18
|
+
connection.create(path, method, params)
|
19
|
+
end
|
20
|
+
|
21
|
+
def parse_response(request)
|
22
|
+
Response.new(request)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def enviroment
|
27
|
+
production ? "https://secure.espago.com/api" : "https://sandbox.espago.com/api"
|
28
|
+
end
|
29
|
+
|
30
|
+
def valid?
|
31
|
+
@app_id && @app_password
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "json"
|
2
|
+
require "time"
|
3
|
+
|
4
|
+
module Espago
|
5
|
+
class Response
|
6
|
+
attr_reader :body
|
7
|
+
|
8
|
+
def initialize(response)
|
9
|
+
@body = parse(response)
|
10
|
+
end
|
11
|
+
|
12
|
+
def response_id
|
13
|
+
body["id"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def description
|
17
|
+
body["description"]
|
18
|
+
end
|
19
|
+
|
20
|
+
def amount
|
21
|
+
body["amount"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def currency
|
25
|
+
body["currency"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def state
|
29
|
+
body["state"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def client
|
33
|
+
body["client"]
|
34
|
+
end
|
35
|
+
|
36
|
+
def created_at
|
37
|
+
body["client"]
|
38
|
+
end
|
39
|
+
|
40
|
+
def card
|
41
|
+
body["card"] || {}
|
42
|
+
end
|
43
|
+
|
44
|
+
def created_at
|
45
|
+
Time.parse body["created_at"]
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def parse(body)
|
51
|
+
JSON.parse body
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "espago/api_connection"
|
2
|
+
|
3
|
+
module Espago
|
4
|
+
class Router
|
5
|
+
attr_accessor :path, :method
|
6
|
+
NoPathError = Class.new(StandardError)
|
7
|
+
|
8
|
+
def initialize(path, method)
|
9
|
+
@path, @method = path, method
|
10
|
+
end
|
11
|
+
|
12
|
+
def route
|
13
|
+
raise NoPathError unless path_exists?
|
14
|
+
get_route
|
15
|
+
end
|
16
|
+
|
17
|
+
def path_exists?
|
18
|
+
get_route
|
19
|
+
true
|
20
|
+
rescue
|
21
|
+
false
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def get_route
|
26
|
+
Espago::ApiConnection.const_get get_class_name
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_class_name
|
30
|
+
method.to_s.capitalize + path.to_s.split("_").map(&:capitalize).join
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "espago/api_connection"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
class StubbedResponse < Struct.new(:body); end
|
6
|
+
|
7
|
+
class Espago::ApiConnection::StubbedPath
|
8
|
+
def initialize(connection); end
|
9
|
+
|
10
|
+
def request(params = {})
|
11
|
+
StubbedResponse.new("{\"data\":\"returned api data\"}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe Espago::ApiConnection do
|
16
|
+
subject { Espago::ApiConnection.new("http://some.api.example.com") }
|
17
|
+
|
18
|
+
context "#create" do
|
19
|
+
it "should return response body in json format" do
|
20
|
+
subject.create(:path, :stubbed).should eq(JSON.parse("{\"data\":\"returned api data\"}"))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'espago/client'
|
3
|
+
|
4
|
+
class StubbedApiConnection
|
5
|
+
def initialize(enviroment); end
|
6
|
+
def authenticate(app_id, app_password); end
|
7
|
+
def create(path, method, params= {})
|
8
|
+
'returned api data'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe Espago::Client do
|
13
|
+
subject { Espago::Client.new( app_id: 'App12345', app_password: 'secret', connection: stubbed_api_connection) }
|
14
|
+
let(:stubbed_api_connection) { StubbedApiConnection }
|
15
|
+
let(:response) { {id: 1, status: "2012"}.to_json }
|
16
|
+
|
17
|
+
it { subject.should respond_to :app_id }
|
18
|
+
it { subject.should respond_to :app_password }
|
19
|
+
it { subject.should respond_to :public_key }
|
20
|
+
|
21
|
+
context "#send_request" do
|
22
|
+
let(:method) { :get }
|
23
|
+
let(:path) { :new_client }
|
24
|
+
let(:params) { { name: "Jan Kowalski"} }
|
25
|
+
|
26
|
+
it "should create an api request" do
|
27
|
+
subject.send_request(path, method, params).should eq('returned api data')
|
28
|
+
end
|
29
|
+
|
30
|
+
context "with no credentials" do
|
31
|
+
subject { Espago::Client.new }
|
32
|
+
|
33
|
+
it "should raise error" do
|
34
|
+
expect { subject.send_request(path, method, params)}.to raise_error(Espago::Client::NotAuthenticated)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "#parse_response" do
|
40
|
+
subject { Espago::Client.new }
|
41
|
+
|
42
|
+
it "should delegate work to parser" do
|
43
|
+
Espago::Response.should_receive(:new).with(response)
|
44
|
+
subject.parse_response(response)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should parse response into object" do
|
48
|
+
subject.parse_response(response).class.should eq(Espago::Response)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'espago/response'
|
3
|
+
|
4
|
+
describe Espago::Response do
|
5
|
+
subject { Espago::Response.new(response)}
|
6
|
+
let(:response) {
|
7
|
+
{
|
8
|
+
id: "pay_hViT20SOWaUL_w",
|
9
|
+
description: "Zakupy z example.com",
|
10
|
+
amount: "49.99",
|
11
|
+
currency: "pln",
|
12
|
+
state: "executed",
|
13
|
+
client: "cli_wm7dGQltAqIfH8",
|
14
|
+
created_at: "20130222161633",
|
15
|
+
card:{
|
16
|
+
company: "VI",
|
17
|
+
last4: "4242",
|
18
|
+
year: 2019,
|
19
|
+
month: 4,
|
20
|
+
first_name: "Piotr",
|
21
|
+
last_name: "Nowak",
|
22
|
+
authorized: true,
|
23
|
+
created_at: "20130222153946"
|
24
|
+
}
|
25
|
+
}.to_json
|
26
|
+
}
|
27
|
+
|
28
|
+
its(:response_id) { should eq("pay_hViT20SOWaUL_w") }
|
29
|
+
its(:description) { should eq("Zakupy z example.com") }
|
30
|
+
its(:amount) { should eq("49.99") }
|
31
|
+
its(:currency) { should eq("pln") }
|
32
|
+
its(:state) { should eq("executed") }
|
33
|
+
its(:client) { should eq("cli_wm7dGQltAqIfH8") }
|
34
|
+
its(:created_at) { should eq(Time.parse("20130222161633")) }
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "espago/router"
|
3
|
+
|
4
|
+
class Espago::ApiConnection::GetStubbedRequest; end
|
5
|
+
|
6
|
+
describe Espago::Router do
|
7
|
+
subject { Espago::Router.new(:stubbed_request, :get) }
|
8
|
+
|
9
|
+
it { subject.should respond_to :path}
|
10
|
+
it { subject.should respond_to :method}
|
11
|
+
|
12
|
+
context "#route" do
|
13
|
+
it "should get a class name depending on path and method" do
|
14
|
+
subject.route.should eq( Espago::ApiConnection::GetStubbedRequest )
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should raise error if class not found" do
|
18
|
+
subject { Espago::Router.new(:not, :existing) }
|
19
|
+
expect { subject.route.to raise_error( Espago::Router::NoPathError ) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "#path_exists?" do
|
24
|
+
it "should return if path exists" do
|
25
|
+
subject.path_exists?.should be_true
|
26
|
+
end
|
27
|
+
|
28
|
+
context "with invalid path name" do
|
29
|
+
subject { Espago::Router.new(:not, :existing) }
|
30
|
+
|
31
|
+
it "should return false" do
|
32
|
+
subject.path_exists?.should_not be_true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
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
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,232 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: espago
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Piotrek
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: facets
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: pry
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: guard-rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: simplecov
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: fuubar
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rake
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: rb-fsevent
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ~>
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 0.9.1
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ~>
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 0.9.1
|
158
|
+
description: Espago api wrapper
|
159
|
+
email:
|
160
|
+
- pkurek90@gmail.com
|
161
|
+
executables: []
|
162
|
+
extensions: []
|
163
|
+
extra_rdoc_files: []
|
164
|
+
files:
|
165
|
+
- .gitignore
|
166
|
+
- .travis.yml
|
167
|
+
- Gemfile
|
168
|
+
- Gemfile.lock
|
169
|
+
- Guardfile
|
170
|
+
- LICENSE.txt
|
171
|
+
- README.md
|
172
|
+
- Rakefile
|
173
|
+
- espago.gemspec
|
174
|
+
- lib/espago.rb
|
175
|
+
- lib/espago/api_connection.rb
|
176
|
+
- lib/espago/api_connection/delete_charges.rb
|
177
|
+
- lib/espago/api_connection/delete_clients.rb
|
178
|
+
- lib/espago/api_connection/get_charges.rb
|
179
|
+
- lib/espago/api_connection/get_clients.rb
|
180
|
+
- lib/espago/api_connection/get_tokens.rb
|
181
|
+
- lib/espago/api_connection/post_charges.rb
|
182
|
+
- lib/espago/api_connection/post_charges_refund.rb
|
183
|
+
- lib/espago/api_connection/post_clients.rb
|
184
|
+
- lib/espago/api_connection/post_clients_authorize.rb
|
185
|
+
- lib/espago/api_connection/post_complete.rb
|
186
|
+
- lib/espago/api_connection/post_tokens.rb
|
187
|
+
- lib/espago/api_connection/put_clients.rb
|
188
|
+
- lib/espago/client.rb
|
189
|
+
- lib/espago/response.rb
|
190
|
+
- lib/espago/router.rb
|
191
|
+
- lib/espago/version.rb
|
192
|
+
- spec/espago/api_connection_spec.rb
|
193
|
+
- spec/espago/client_spec.rb
|
194
|
+
- spec/espago/response_spec.rb
|
195
|
+
- spec/espago/router_spec.rb
|
196
|
+
- spec/spec_helper.rb
|
197
|
+
homepage: ''
|
198
|
+
licenses: []
|
199
|
+
post_install_message:
|
200
|
+
rdoc_options: []
|
201
|
+
require_paths:
|
202
|
+
- lib
|
203
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
204
|
+
none: false
|
205
|
+
requirements:
|
206
|
+
- - ! '>='
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
segments:
|
210
|
+
- 0
|
211
|
+
hash: 3240784563550690140
|
212
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
|
+
none: false
|
214
|
+
requirements:
|
215
|
+
- - ! '>='
|
216
|
+
- !ruby/object:Gem::Version
|
217
|
+
version: '0'
|
218
|
+
segments:
|
219
|
+
- 0
|
220
|
+
hash: 3240784563550690140
|
221
|
+
requirements: []
|
222
|
+
rubyforge_project:
|
223
|
+
rubygems_version: 1.8.24
|
224
|
+
signing_key:
|
225
|
+
specification_version: 3
|
226
|
+
summary: Espago api wrapper
|
227
|
+
test_files:
|
228
|
+
- spec/espago/api_connection_spec.rb
|
229
|
+
- spec/espago/client_spec.rb
|
230
|
+
- spec/espago/response_spec.rb
|
231
|
+
- spec/espago/router_spec.rb
|
232
|
+
- spec/spec_helper.rb
|