API2Cart 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/api2cart.rb +28 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f8a6c246bc1c485c07b40f51b04613eddb384068
|
4
|
+
data.tar.gz: 67d148465061eef77aacf22f12c48f78426185cd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 201b04148d8ce1711421bda24bfb8e89bfc66efdd8ac5ff3c9195ef7e51001b238fef97bd72438c3f1c52c0de257ec01ba4be5adb613ff4e90166ec372f8caac
|
7
|
+
data.tar.gz: 93026c467d7a0716396f87da12e6b5c61733aec99dc8c7dfe7612ef4d31adf77c90cbc20a0de73f819afaecb04b90e03d993ed533722277db7d9506a294141e0
|
data/lib/api2cart.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module API2Cart
|
5
|
+
DOMAIN = 'api.api2cart.com'
|
6
|
+
API_VERSION = 'v1.0'
|
7
|
+
FORMAT = 'json'
|
8
|
+
|
9
|
+
class Store
|
10
|
+
def initialize(api_key, store_key)
|
11
|
+
@api_key = api_key
|
12
|
+
@store_key = store_key
|
13
|
+
end
|
14
|
+
|
15
|
+
def method_missing(method, *args)
|
16
|
+
method_name = method.to_s.split('_').push(FORMAT).join('.')
|
17
|
+
params = {api_key: @api_key, store_key: @store_key}.merge(args[0] ? args[0] : {})
|
18
|
+
query_string = URI.encode(params.map{|k,v| "#{k}=#{v}"}.join("&"))
|
19
|
+
response = Net::HTTP.get_response(DOMAIN,"/#{API_VERSION}/#{method_name}?#{query_string}")
|
20
|
+
data = JSON.parse(response.body)
|
21
|
+
if data['return_code'] == 0
|
22
|
+
data['result']
|
23
|
+
else
|
24
|
+
raise data['return_message']
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: API2Cart
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Volodymyr Shatsky
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Ruby toolkit for the API2Cart API
|
14
|
+
email: v.shatsky@magneticone.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/api2cart.rb
|
20
|
+
homepage: http://api2cart.com
|
21
|
+
licenses: []
|
22
|
+
metadata: {}
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
requirements: []
|
38
|
+
rubyforge_project:
|
39
|
+
rubygems_version: 2.0.3
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Ruby toolkit for the API2Cart API
|
43
|
+
test_files: []
|