api2cart-ruby 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +43 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/api2cart-ruby.gemspec +29 -0
- data/lib/api2cart/client.rb +45 -0
- data/lib/api2cart/request_url_composer.rb +27 -0
- data/lib/api2cart/store.rb +24 -0
- data/lib/api2cart/version.rb +3 -0
- data/lib/api2cart.rb +6 -0
- data/spec/api2cart/client_spec.rb +56 -0
- data/spec/api2cart/request_url_composer_spec.rb +81 -0
- data/spec/api2cart/store_spec.rb +20 -0
- data/spec/api2cart/with_proxy_spec.rb +19 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/vcr_cassettes/erroneous_request.yml +55 -0
- data/spec/vcr_cassettes/successful_request.yml +54 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d8a472dead7ba8d39e0adf36a51501e9e5236d78
|
4
|
+
data.tar.gz: 0e366296723d174613b001cad9575c497d3c37ff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2204bc93466eb3ddbffb99af8132702b253addbcd648289bdc86690a782cef9a23ec47d43713be98b9054972270c1127eaab13c85f49fc7c5fbb5dcd65b97b5a
|
7
|
+
data.tar.gz: f67f081652e8538173c6bf85c59a367264e912ff79c28815df92af8a9cd927bc4941e2961dcca0a34d5f0534e51e5f900a55168d37cc42a358425ea794b4a2c1
|
data/.gitignore
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
35
|
+
|
36
|
+
/Gemfile.lock
|
37
|
+
/spec/reports/
|
38
|
+
*.bundle
|
39
|
+
*.so
|
40
|
+
*.o
|
41
|
+
*.a
|
42
|
+
mkmf.log
|
43
|
+
/eproject.cfg
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Daniel Vartanov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Api2cart
|
2
|
+
|
3
|
+
Ruby client for [API2Cart](https://www.api2cart.com/) with proxy support, fully covered with tests.
|
4
|
+
The DSL is similar to DSL of [original gem](https://rubygems.org/gems/API2Cart) therefore migration is easy.
|
5
|
+
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'api2cart-ruby', require: 'api2cart'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install api2cart-ruby
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
Api2cart::Store.new(api_key, store_key).product_count
|
25
|
+
# => { 'products_count' => 76 }
|
26
|
+
```
|
27
|
+
|
28
|
+
With proxy:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
Api2cart::Store.new(api_key, store_key, proxy: 'http://anti-throttling-proxy.local:1080').product_count
|
32
|
+
# => { 'products_count' => 76 }
|
33
|
+
```
|
34
|
+
|
35
|
+
Sponsored by [Veeqo](https://github.com/veeqo)
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'api2cart/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "api2cart-ruby"
|
8
|
+
spec.version = Api2cart::VERSION
|
9
|
+
|
10
|
+
spec.authors = ["Tom Procter", "Daniel Vartanov"].sort
|
11
|
+
spec.email = ["tom@procterweb.co.uk", "dan@vartanov.net"]
|
12
|
+
|
13
|
+
spec.summary = %q{Ruby client for API2Cart}
|
14
|
+
spec.description = %q{Ruby client for API2Cart with proxy support}
|
15
|
+
spec.homepage = "https://github.com/DanielVartanov/api2cart-ruby"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0")
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency "activesupport"
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
spec.add_development_dependency "vcr"
|
28
|
+
spec.add_development_dependency "webmock"
|
29
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
require 'active_support/core_ext/object/blank'
|
4
|
+
|
5
|
+
module Api2cart
|
6
|
+
class Client < Struct.new(:request_url, :proxy_url)
|
7
|
+
def make_request!
|
8
|
+
self.response_body = net_http_class.get_response(request_url).body
|
9
|
+
end
|
10
|
+
|
11
|
+
def successful?
|
12
|
+
return_code == 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def error_message
|
16
|
+
response_json['return_message']
|
17
|
+
end
|
18
|
+
|
19
|
+
def result
|
20
|
+
response_json['result']
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
attr_accessor :response_body
|
26
|
+
|
27
|
+
def response_json
|
28
|
+
@response_json ||= JSON.parse response_body
|
29
|
+
end
|
30
|
+
|
31
|
+
def return_code
|
32
|
+
response_json['return_code']
|
33
|
+
end
|
34
|
+
|
35
|
+
def parsed_proxy_url
|
36
|
+
@parsed_proxy_url ||= URI.parse proxy_url
|
37
|
+
end
|
38
|
+
|
39
|
+
def net_http_class
|
40
|
+
proxy_url.present? ?
|
41
|
+
Net::HTTP::Proxy(parsed_proxy_url.host, parsed_proxy_url.port) :
|
42
|
+
Net::HTTP
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'active_support/core_ext/object/to_query'
|
3
|
+
|
4
|
+
module Api2cart
|
5
|
+
class RequestUrlComposer < Struct.new(:api_key, :store_key, :method_name, :query_params)
|
6
|
+
HOST = 'api.api2cart.com'
|
7
|
+
PATH_BASE = '/v1.0'
|
8
|
+
|
9
|
+
def compose_request_url
|
10
|
+
URI::HTTP.build host: HOST, path: full_path, query: query_string
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def full_path
|
16
|
+
"#{PATH_BASE}/#{dotted_method_name}.json"
|
17
|
+
end
|
18
|
+
|
19
|
+
def dotted_method_name
|
20
|
+
method_name.to_s.gsub('_', '.')
|
21
|
+
end
|
22
|
+
|
23
|
+
def query_string
|
24
|
+
{ api_key: api_key, store_key: store_key }.merge(query_params || {}).to_param
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Api2cart
|
2
|
+
class Store
|
3
|
+
attr_accessor :api_key, :store_key, :proxy
|
4
|
+
|
5
|
+
def initialize(api_key, store_key, proxy: nil)
|
6
|
+
self.api_key = api_key
|
7
|
+
self.store_key = store_key
|
8
|
+
self.proxy = proxy
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(method_name, *args)
|
12
|
+
request_url = RequestUrlComposer.new(api_key, store_key, method_name, args.first).compose_request_url
|
13
|
+
|
14
|
+
api2cart_client = Client.new(request_url, proxy)
|
15
|
+
api2cart_client.make_request!
|
16
|
+
|
17
|
+
if api2cart_client.successful?
|
18
|
+
api2cart_client.result
|
19
|
+
else
|
20
|
+
raise api2cart_client.error_message
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/api2cart.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
describe Api2cart::Client do
|
2
|
+
let(:api2cart_client) { Api2cart::Client.new(request_url) }
|
3
|
+
|
4
|
+
before { api2cart_client.make_request! }
|
5
|
+
|
6
|
+
context 'when request is successful', vcr: { cassette_name: 'successful_request' } do
|
7
|
+
let(:api_key) { '43ba7043badfa2cd31cfaf5dc601a884' }
|
8
|
+
let(:store_key) { '6f00bbf49f5ada8156506aba161408c6' }
|
9
|
+
|
10
|
+
let(:request_url) { Api2cart::RequestUrlComposer.new(api_key, store_key, :product_count).compose_request_url }
|
11
|
+
|
12
|
+
describe '#successful?' do
|
13
|
+
subject { api2cart_client.successful? }
|
14
|
+
|
15
|
+
it { is_expected.to be true }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#error_message' do
|
19
|
+
subject { api2cart_client.error_message }
|
20
|
+
|
21
|
+
it { is_expected.to eq '' }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#result' do
|
25
|
+
subject { api2cart_client.result }
|
26
|
+
|
27
|
+
it 'returns result as parsed JSON' do
|
28
|
+
expect(subject).to eq({ "products_count" => 76 })
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when request is erroneous', vcr: { cassette_name: 'erroneous_request' } do
|
34
|
+
let(:request_url) { Api2cart::RequestUrlComposer.new('wrong', 'even more wrong', :product_count).compose_request_url }
|
35
|
+
|
36
|
+
describe '#successful?' do
|
37
|
+
subject { api2cart_client.successful? }
|
38
|
+
|
39
|
+
it { is_expected.to be false }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#error_message' do
|
43
|
+
subject { api2cart_client.error_message }
|
44
|
+
|
45
|
+
it 'parses request and extracts error message' do
|
46
|
+
expect(subject).to eq 'Incorrect API Key'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#result' do
|
51
|
+
subject { api2cart_client.result }
|
52
|
+
|
53
|
+
it { is_expected.to eq({}) }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
describe Api2cart::RequestUrlComposer do
|
2
|
+
let(:api_key) { '43ba7043badfa2cd31cfaf5dc601a884' }
|
3
|
+
let(:store_key) { '6f00bbf49f5ada8156506aba161408c6' }
|
4
|
+
let(:method_name) { :order_list }
|
5
|
+
let(:query_params) do
|
6
|
+
{
|
7
|
+
params: 'force_all',
|
8
|
+
start: 20,
|
9
|
+
count: 10
|
10
|
+
}
|
11
|
+
end
|
12
|
+
let(:request_url_composer) { Api2cart::RequestUrlComposer.new(api_key, store_key, method_name, query_params) }
|
13
|
+
|
14
|
+
let(:composed_url) { request_url_composer.compose_request_url }
|
15
|
+
|
16
|
+
describe 'protocol' do
|
17
|
+
subject { composed_url.scheme }
|
18
|
+
|
19
|
+
specify do
|
20
|
+
expect(subject).to eq('http')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'domain' do
|
25
|
+
subject { composed_url.host }
|
26
|
+
|
27
|
+
specify do
|
28
|
+
expect(subject).to eq('api.api2cart.com')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'path' do
|
33
|
+
subject { composed_url.path }
|
34
|
+
|
35
|
+
it 'contains API version in the beginning' do
|
36
|
+
expect(subject).to start_with('/v1.0')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'contains method name translating underscores to dots' do
|
40
|
+
expect(subject).to start_with('/v1.0/order.list')
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'contains indicator of JSON format' do
|
44
|
+
expect(subject).to start_with('/v1.0/order.list.json')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'query string' do
|
49
|
+
subject { composed_url.query }
|
50
|
+
|
51
|
+
it 'contains API key' do
|
52
|
+
expect(subject).to include('api_key=43ba7043badfa2cd31cfaf5dc601a884')
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'contains store key' do
|
56
|
+
expect(subject).to include('store_key=6f00bbf49f5ada8156506aba161408c6')
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'translates method arguments to query params' do
|
60
|
+
expect(subject).to include('count=10¶ms=force_all&start=20')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'all together' do
|
65
|
+
subject { composed_url.to_s }
|
66
|
+
|
67
|
+
it do
|
68
|
+
is_expected.to eq 'http://api.api2cart.com/v1.0/order.list.json?api_key=43ba7043badfa2cd31cfaf5dc601a884&count=10¶ms=force_all&start=20&store_key=6f00bbf49f5ada8156506aba161408c6'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when there is no arguments' do
|
73
|
+
subject { composed_url.to_s }
|
74
|
+
|
75
|
+
let(:request_url_composer) { Api2cart::RequestUrlComposer.new(api_key, store_key, :product_count, nil) }
|
76
|
+
|
77
|
+
it 'just does not add them to URL query' do
|
78
|
+
is_expected.to eq 'http://api.api2cart.com/v1.0/product.count.json?api_key=43ba7043badfa2cd31cfaf5dc601a884&store_key=6f00bbf49f5ada8156506aba161408c6'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Api2cart::Store do
|
4
|
+
context 'when request is successful', vcr: { cassette_name: 'successful_request' } do
|
5
|
+
let(:api_key) { '43ba7043badfa2cd31cfaf5dc601a884' }
|
6
|
+
let(:store_key) { '6f00bbf49f5ada8156506aba161408c6' }
|
7
|
+
|
8
|
+
it 'returns parsed JSON' do
|
9
|
+
expect(Api2cart::Store.new(api_key, store_key).product_count).to eq({ 'products_count' => 76 })
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'when response contains an error', vcr: { cassette_name: 'erroneous_request' } do
|
14
|
+
it 'raises an exception with correspondent message' do
|
15
|
+
expect {
|
16
|
+
Api2cart::Store.new('wrong', 'even more wrong').product_count
|
17
|
+
}.to raise_error('Incorrect API Key')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Api2cart do
|
4
|
+
context 'when proxy URL is given', vcr: { cassette_name: 'successful_request' } do
|
5
|
+
let(:api_key) { '43ba7043badfa2cd31cfaf5dc601a884' }
|
6
|
+
let(:store_key) { '6f00bbf49f5ada8156506aba161408c6' }
|
7
|
+
|
8
|
+
let(:store_with_proxy) { Api2cart::Store.new api_key, store_key, proxy: 'http://anti-throttling-proxy.local:1080' }
|
9
|
+
|
10
|
+
it 'sends request via proxy (see cassette)' do
|
11
|
+
expect(store_with_proxy.product_count).to eq({ 'products_count' => 76 })
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'extracts hostname and port from proxy URL' do
|
15
|
+
expect(Net::HTTP).to receive(:Proxy).with('anti-throttling-proxy.local', 1080).and_call_original
|
16
|
+
store_with_proxy.product_count
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative File.join(__dir__, '../lib/api2cart')
|
2
|
+
|
3
|
+
require 'rspec/core'
|
4
|
+
require 'webmock'
|
5
|
+
require 'vcr'
|
6
|
+
|
7
|
+
Dir[File.join(__dir__, "support/**/*.rb")].each { |f| require f }
|
8
|
+
Dir[File.join(__dir__, "shared_examples/**/*.rb")].sort.each { |f| require f }
|
9
|
+
|
10
|
+
VCR.configure do |c|
|
11
|
+
c.cassette_library_dir = File.join(__dir__, "vcr_cassettes")
|
12
|
+
c.configure_rspec_metadata!
|
13
|
+
c.hook_into :webmock
|
14
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://api.api2cart.com/v1.0/product.count.json?api_key=wrong&store_key=even%20more%20wrong
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- '*/*'
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Host:
|
17
|
+
- api.api2cart.com
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Date:
|
24
|
+
- Wed, 19 Nov 2014 10:21:28 GMT
|
25
|
+
Server:
|
26
|
+
- Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1e-fips mod_bwlimited/1.4
|
27
|
+
mod_fcgid/2.3.9
|
28
|
+
X-Powered-By:
|
29
|
+
- PHP/5.3.28
|
30
|
+
Expires:
|
31
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
32
|
+
Cache-Control:
|
33
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
34
|
+
Pragma:
|
35
|
+
- no-cache
|
36
|
+
Set-Cookie:
|
37
|
+
- PHPSESSID=c217cbe8ce21f4304c661d65c982e47c; expires=Wed, 19-Nov-2014 12:21:28
|
38
|
+
GMT; path=/
|
39
|
+
Access-Control-Allow-Origin:
|
40
|
+
- '*'
|
41
|
+
Access-Control-Allow-Headers:
|
42
|
+
- origin, x-requested-with, content-type
|
43
|
+
Access-Control-Allow-Methods:
|
44
|
+
- PUT, GET, POST, DELETE, OPTIONS
|
45
|
+
Transfer-Encoding:
|
46
|
+
- chunked
|
47
|
+
Content-Type:
|
48
|
+
- application/json; charset=utf-8
|
49
|
+
body:
|
50
|
+
encoding: UTF-8
|
51
|
+
string: '{"return_code" : 2, "return_message": "Incorrect API Key", "result"
|
52
|
+
: {}}'
|
53
|
+
http_version:
|
54
|
+
recorded_at: Wed, 19 Nov 2014 10:21:28 GMT
|
55
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://api.api2cart.com/v1.0/product.count.json?api_key=43ba7043badfa2cd31cfaf5dc601a884&store_key=6f00bbf49f5ada8156506aba161408c6
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- '*/*'
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Host:
|
17
|
+
- api.api2cart.com
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Date:
|
24
|
+
- Wed, 19 Nov 2014 10:20:29 GMT
|
25
|
+
Server:
|
26
|
+
- Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1e-fips mod_bwlimited/1.4
|
27
|
+
mod_fcgid/2.3.9
|
28
|
+
X-Powered-By:
|
29
|
+
- PHP/5.3.28
|
30
|
+
Expires:
|
31
|
+
- Thu, 19 Nov 1981 08:52:00 GMT
|
32
|
+
Cache-Control:
|
33
|
+
- no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
34
|
+
Pragma:
|
35
|
+
- no-cache
|
36
|
+
Set-Cookie:
|
37
|
+
- PHPSESSID=b1ea7d1fe638a3d718f4f13215204054; expires=Wed, 19-Nov-2014 12:20:29
|
38
|
+
GMT; path=/
|
39
|
+
Access-Control-Allow-Origin:
|
40
|
+
- '*'
|
41
|
+
Access-Control-Allow-Headers:
|
42
|
+
- origin, x-requested-with, content-type
|
43
|
+
Access-Control-Allow-Methods:
|
44
|
+
- PUT, GET, POST, DELETE, OPTIONS
|
45
|
+
Transfer-Encoding:
|
46
|
+
- chunked
|
47
|
+
Content-Type:
|
48
|
+
- application/json; charset=utf-8
|
49
|
+
body:
|
50
|
+
encoding: UTF-8
|
51
|
+
string: '{"return_code" : 0, "return_message": "", "result" : {"products_count":76}}'
|
52
|
+
http_version:
|
53
|
+
recorded_at: Wed, 19 Nov 2014 10:20:29 GMT
|
54
|
+
recorded_with: VCR 2.9.3
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: api2cart-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Vartanov
|
8
|
+
- Tom Procter
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.7'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.7'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '10.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '10.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: vcr
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: webmock
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
description: Ruby client for API2Cart with proxy support
|
99
|
+
email:
|
100
|
+
- tom@procterweb.co.uk
|
101
|
+
- dan@vartanov.net
|
102
|
+
executables: []
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- .gitignore
|
107
|
+
- .rspec
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- api2cart-ruby.gemspec
|
113
|
+
- lib/api2cart.rb
|
114
|
+
- lib/api2cart/client.rb
|
115
|
+
- lib/api2cart/request_url_composer.rb
|
116
|
+
- lib/api2cart/store.rb
|
117
|
+
- lib/api2cart/version.rb
|
118
|
+
- spec/api2cart/client_spec.rb
|
119
|
+
- spec/api2cart/request_url_composer_spec.rb
|
120
|
+
- spec/api2cart/store_spec.rb
|
121
|
+
- spec/api2cart/with_proxy_spec.rb
|
122
|
+
- spec/spec_helper.rb
|
123
|
+
- spec/vcr_cassettes/erroneous_request.yml
|
124
|
+
- spec/vcr_cassettes/successful_request.yml
|
125
|
+
homepage: https://github.com/DanielVartanov/api2cart-ruby
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata: {}
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 2.4.2
|
146
|
+
signing_key:
|
147
|
+
specification_version: 4
|
148
|
+
summary: Ruby client for API2Cart
|
149
|
+
test_files:
|
150
|
+
- spec/api2cart/client_spec.rb
|
151
|
+
- spec/api2cart/request_url_composer_spec.rb
|
152
|
+
- spec/api2cart/store_spec.rb
|
153
|
+
- spec/api2cart/with_proxy_spec.rb
|
154
|
+
- spec/spec_helper.rb
|
155
|
+
- spec/vcr_cassettes/erroneous_request.yml
|
156
|
+
- spec/vcr_cassettes/successful_request.yml
|