qaddy-client 0.0.8 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/qaddy_client/helpers.rb +0 -6
- data/lib/qaddy_client/version.rb +1 -1
- data/lib/qaddy_client.rb +40 -10
- data/qaddy-client.gemspec +3 -3
- metadata +6 -6
data/lib/qaddy_client/helpers.rb
CHANGED
@@ -2,17 +2,11 @@ module QaddyClient
|
|
2
2
|
module Helpers
|
3
3
|
|
4
4
|
def instance_variables_to_hash
|
5
|
-
# TODO: just testing, remove for production
|
6
|
-
raise "crash me" if caller.length > 100
|
7
|
-
puts "BEG: instance_variables_to_hash"
|
8
|
-
|
9
5
|
h = {}
|
10
6
|
instance_variables.each do |e|
|
11
|
-
puts "MID: instance_variables_to_hash"
|
12
7
|
o = instance_variable_get e.to_sym
|
13
8
|
h[e[1..-1]] = (o.respond_to? :instance_variables_to_hash) ? o.instance_variables_to_hash : o;
|
14
9
|
end
|
15
|
-
puts "END: instance_variables_to_hash"
|
16
10
|
h
|
17
11
|
end
|
18
12
|
|
data/lib/qaddy_client/version.rb
CHANGED
data/lib/qaddy_client.rb
CHANGED
@@ -23,15 +23,48 @@ module QaddyClient
|
|
23
23
|
yield(configuration) if block_given?
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
# API methods
|
27
|
+
|
28
|
+
def self.post_order_register order
|
29
|
+
begin
|
30
|
+
resource = self.new_resource "/webstores/#{self.configuration.webstore_id}/orders"
|
31
|
+
rcresponse = self.do_post resource, order
|
32
|
+
rescue RestClient::Exception => e
|
33
|
+
self.raise_exception e
|
34
|
+
end
|
35
|
+
QaddyClient::Response.new rcresponse
|
28
36
|
end
|
29
37
|
|
30
|
-
def self.
|
31
|
-
url = self.create_url("/webstores/#{self.configuration.webstore_id}/orders")
|
38
|
+
def self.test
|
32
39
|
begin
|
33
|
-
|
40
|
+
resource = self.new_resource "/webstores/#{self.configuration.webstore_id}/test"
|
41
|
+
rcresponse = self.do_get resource
|
34
42
|
rescue RestClient::Exception => e
|
43
|
+
self.raise_exception e
|
44
|
+
end
|
45
|
+
QaddyClient::Response.new rcresponse
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def self.new_resource path
|
52
|
+
RestClient::Resource.new self.create_url(path), self.configuration.user_id, self.configuration.user_api_key
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.do_get resource
|
56
|
+
resource.get accept: :json
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.do_post resource, body
|
60
|
+
resource.post body.to_json, accept: :json, content_type: :json
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.create_url path
|
64
|
+
"#{self.configuration.api_scheme}://#{self.configuration.api_host}#{self.configuration.api_prefix_path}#{path}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.raise_exception e
|
35
68
|
klass = case e.http_code
|
36
69
|
when 401 then QaddyClient::Errors::Unauthorized
|
37
70
|
when 402 then QaddyClient::Errors::VerificationRequired
|
@@ -45,11 +78,8 @@ module QaddyClient
|
|
45
78
|
end
|
46
79
|
|
47
80
|
qerror = klass.new(e.message, e.response)
|
48
|
-
qerror.set_backtrace
|
49
|
-
raise
|
81
|
+
qerror.set_backtrace e.backtrace
|
82
|
+
raise qerror
|
50
83
|
end
|
51
84
|
|
52
|
-
QaddyClient::Response.new(rcresponse)
|
53
|
-
end
|
54
|
-
|
55
85
|
end
|
data/qaddy-client.gemspec
CHANGED
@@ -7,9 +7,9 @@ Gem::Specification.new do |gem|
|
|
7
7
|
|
8
8
|
gem.authors = ["Zoran Mijatovic"]
|
9
9
|
gem.email = ["zmijatovic@alturabit.com"]
|
10
|
-
gem.description = %q{
|
11
|
-
gem.summary = %q{
|
12
|
-
gem.homepage = ""
|
10
|
+
gem.description = %q{LaComparto API client}
|
11
|
+
gem.summary = %q{LaComparto API ruby client library }
|
12
|
+
gem.homepage = "https://lacomparto.com"
|
13
13
|
|
14
14
|
gem.files = `git ls-files`.split($\)
|
15
15
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qaddy-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
description:
|
62
|
+
description: LaComparto API client
|
63
63
|
email:
|
64
64
|
- zmijatovic@alturabit.com
|
65
65
|
executables: []
|
@@ -80,7 +80,7 @@ files:
|
|
80
80
|
- lib/qaddy_client/response.rb
|
81
81
|
- lib/qaddy_client/version.rb
|
82
82
|
- qaddy-client.gemspec
|
83
|
-
homepage:
|
83
|
+
homepage: https://lacomparto.com
|
84
84
|
licenses: []
|
85
85
|
post_install_message:
|
86
86
|
rdoc_options: []
|
@@ -100,8 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 1.8.
|
103
|
+
rubygems_version: 1.8.25
|
104
104
|
signing_key:
|
105
105
|
specification_version: 3
|
106
|
-
summary:
|
106
|
+
summary: LaComparto API ruby client library
|
107
107
|
test_files: []
|