coinsetter 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/coinsetter.gemspec +1 -1
- data/lib/coinsetter/client_sessions.rb +1 -1
- data/lib/coinsetter/net.rb +49 -7
- data/lib/coinsetter/version.rb +1 -1
- data/lib/coinsetter.rb +11 -5
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aedfcd337a3f59c601cbd025d7468061811e0572
|
4
|
+
data.tar.gz: 4512405dec9f1052afe28b08202535cd54ce6ade
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ab4587aac672330aed95d0f763d5a59788d3408c7ec1722af41f8a0e23454bcc88df4b1e5f0c93869c913d95f0cadbfb279c4d0c832d65ca9b7fb36eb417926
|
7
|
+
data.tar.gz: f6d4aee9db741e02b4944c0131a18baaa68fd936bf6dac97c4099c0fb27ae86db53fe71e5326b0f577e15962709a17b7dbe21971ae7d00b609705a4882d56967
|
data/Gemfile
CHANGED
data/coinsetter.gemspec
CHANGED
@@ -25,5 +25,5 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
spec.add_runtime_dependency('activemodel', ['>= 4.1'])
|
27
27
|
spec.add_runtime_dependency('activesupport', ['>= 4.1'])
|
28
|
-
spec.add_runtime_dependency('
|
28
|
+
spec.add_runtime_dependency('faraday', ['0.9.1'])
|
29
29
|
end
|
@@ -6,7 +6,7 @@ module Coinsetter
|
|
6
6
|
uuid: "38363173-e6fd-4f3a-8146-9ba50da2b1e3",
|
7
7
|
message: "OK",
|
8
8
|
requestStatus: "SUCCESS",
|
9
|
-
userName: "johnqsmith",
|
9
|
+
userName: "johnqsmith#{rand(100)}",
|
10
10
|
customerUuid: "b20ba985-827d-42f7-a355-37e699ac964b",
|
11
11
|
customerStatus: "ACTIVE"
|
12
12
|
})
|
data/lib/coinsetter/net.rb
CHANGED
@@ -1,23 +1,65 @@
|
|
1
1
|
module Coinsetter
|
2
2
|
module Net
|
3
|
-
def self.uri
|
4
|
-
|
3
|
+
def self.uri
|
4
|
+
Coinsetter.configuration.uri
|
5
5
|
end
|
6
6
|
|
7
|
-
def self.get(path, headers={})
|
8
|
-
|
7
|
+
def self.get(path, args={}, headers={})
|
8
|
+
res = connection.get do |req|
|
9
|
+
req.url path, args
|
10
|
+
req.headers["Accept"] = "application/json"
|
11
|
+
req.headers.merge!(headers)
|
12
|
+
end
|
13
|
+
|
14
|
+
body(res)
|
9
15
|
end
|
10
16
|
|
11
17
|
def self.post(path, args={}, headers={})
|
12
|
-
|
18
|
+
res = connection.post do |req|
|
19
|
+
req.url path
|
20
|
+
req.headers['Content-Type'] = 'application/json'
|
21
|
+
req.headers.merge!(headers)
|
22
|
+
req.body = JSON.generate(args)
|
23
|
+
end
|
24
|
+
|
25
|
+
body(res)
|
13
26
|
end
|
14
27
|
|
15
28
|
def self.put(path, args={}, headers={})
|
16
|
-
|
29
|
+
res = connection.put do |req|
|
30
|
+
req.url path
|
31
|
+
req.headers["Accept"] = "application/json"
|
32
|
+
req.headers.merge!(headers)
|
33
|
+
req.body = JSON.generate(args)
|
34
|
+
end
|
35
|
+
|
36
|
+
body(res)
|
17
37
|
end
|
18
38
|
|
19
39
|
def self.delete(path, headers={})
|
20
|
-
|
40
|
+
res = connection.delete do |req|
|
41
|
+
req.url path
|
42
|
+
req.headers["Accept"] = "application/json"
|
43
|
+
req.headers.merge!(headers)
|
44
|
+
end
|
45
|
+
|
46
|
+
body(res)
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.body(res)
|
50
|
+
if res.status == 403
|
51
|
+
"403 - Forbidden: You don't have permission to access"
|
52
|
+
else
|
53
|
+
res.body
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.connection
|
58
|
+
@@connection ||= Faraday.new(url: uri) do |faraday|
|
59
|
+
faraday.request :url_encoded
|
60
|
+
faraday.response :logger
|
61
|
+
faraday.adapter Faraday.default_adapter
|
62
|
+
end
|
21
63
|
end
|
22
64
|
end
|
23
65
|
end
|
data/lib/coinsetter/version.rb
CHANGED
data/lib/coinsetter.rb
CHANGED
@@ -5,7 +5,7 @@ require 'active_support'
|
|
5
5
|
require 'active_support/core_ext'
|
6
6
|
require 'active_support/inflector'
|
7
7
|
require 'active_model'
|
8
|
-
require '
|
8
|
+
require 'faraday'
|
9
9
|
|
10
10
|
require "coinsetter/configuration"
|
11
11
|
require "coinsetter/net"
|
@@ -39,17 +39,23 @@ module Coinsetter
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.with_session
|
42
|
-
session = ClientSessions.new
|
43
|
-
client_session = session.create(credentials)
|
44
|
-
|
45
42
|
if client_session.kind_of? ClientSession
|
46
43
|
yield client_session if block_given?
|
47
|
-
|
44
|
+
destroy_client_session!
|
48
45
|
else
|
49
46
|
client_session
|
50
47
|
end
|
51
48
|
end
|
52
49
|
|
50
|
+
def self.client_session
|
51
|
+
@client_session ||= ClientSessions.new.create(credentials)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.destroy_client_session!
|
55
|
+
client_session.destroy!
|
56
|
+
@client_session = nil
|
57
|
+
end
|
58
|
+
|
53
59
|
def self.orders
|
54
60
|
@@orders ||= Orders.new
|
55
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coinsetter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis Galaviz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -95,19 +95,19 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '4.1'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: faraday
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.9.1
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.9.1
|
111
111
|
description: Simple API connection to Coinsetter.
|
112
112
|
email:
|
113
113
|
- galaviz.lm@gmail.com
|