cc-cli 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/config.yml +2 -2
- data/lib/cc/api/explorer.rb +2 -4
- data/lib/cc/api/explorer/version.rb +1 -1
- data/lib/cc/api/http/http_requestor.rb +0 -2
- data/lib/cc/api/parser/arguments_parser.rb +2 -2
- data/spec/explorer_spec.rb +2 -2
- data/spec/parser/arguments_parser_spec.rb +3 -4
- metadata +1 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a6499c59d6b1c19b2f28d257f8bc96704d63093
|
4
|
+
data.tar.gz: 2a7199f0bab2143a083d525061111069e0d05778
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c61dc6b46eca5abbabccf0cf679353893c8d5f29074c65cb7e9d37106e056ca87d60ad5d3a6bbd00e222a3910b829be5f25098e9eb1de3d0bf3388e00907c75
|
7
|
+
data.tar.gz: 4e2fd374219d622691e234dec2e870bc36c0aef7577823d5f503fb6e5704257b6d137366654cf96336607a0f6538030a0b2dfe5361a27a4a3c6b1a69893a4c82
|
data/config/config.yml
CHANGED
@@ -25,7 +25,7 @@ catalog:
|
|
25
25
|
url: https://api.crystalcommerce.com/v1/catalog/categories
|
26
26
|
target_key_chain: "categories"
|
27
27
|
store:
|
28
|
-
products:
|
29
|
-
url: https
|
28
|
+
products:
|
29
|
+
url: https://api.crystalcommerce.com/v1/stores/:db/products
|
30
30
|
target_key_chain: "paginated_collection.entries"
|
31
31
|
ignores: ["product.descriptors"]
|
data/lib/cc/api/explorer.rb
CHANGED
@@ -37,7 +37,6 @@ module Cc
|
|
37
37
|
"id" => "Product ID",
|
38
38
|
"skus" => "SKUs separated by ',' if more than one",
|
39
39
|
"page" => "Page number of the response",
|
40
|
-
"token" => "OAuth Token",
|
41
40
|
"store" => "Store name (CrystalCommerce Client)",
|
42
41
|
"csv" => "Print out the result into a csv file. Columns are separated by comma"
|
43
42
|
}
|
@@ -117,15 +116,14 @@ module Cc
|
|
117
116
|
option :colp, :type => :numeric, :desc => DESC["colp"]
|
118
117
|
option :json, :type => :boolean, :desc => DESC["json"]
|
119
118
|
option :page, :type => :numeric, :desc => DESC["page"]
|
120
|
-
option :token, :desc => DESC["token"]
|
121
119
|
option :store, :desc => DESC["store"]
|
122
120
|
|
123
|
-
desc "store [products --
|
121
|
+
desc "store [products --store <store name>]", "The Store Data API provides access to the data related to a single store whereas the Market Data API applies to all stores."
|
124
122
|
def store(subcommand)
|
125
123
|
case subcommand
|
126
124
|
when "products"
|
127
125
|
# { paginated_collection : { entries : [ { product: { ... } } ] } }
|
128
|
-
args = {:action => "store-products", :params => {:
|
126
|
+
args = {:action => "store-products", :params => {:store => options[:store], :page => options[:page] || 1} }
|
129
127
|
perform(args)
|
130
128
|
else
|
131
129
|
Cc::Api::Parser::ArgumentsParser.raise_cli_arguments_exception
|
@@ -19,8 +19,6 @@ module Cc
|
|
19
19
|
:body => params[:request][:body].to_json,
|
20
20
|
:headers => { 'Content-Type' => 'application/json' }
|
21
21
|
)
|
22
|
-
elsif params[:request][:token]
|
23
|
-
response_body = HTTParty.get(params[:request][:url], :headers => { "Authorization" => "OAuth #{params[:request][:token]}"})
|
24
22
|
else
|
25
23
|
response_body = HTTParty.get(params[:request][:url], :basic_auth => basic_auth)
|
26
24
|
end
|
@@ -7,7 +7,7 @@ module Cc
|
|
7
7
|
end
|
8
8
|
|
9
9
|
class ArgumentsParser
|
10
|
-
ERRORS = {'cli_arguments_exception' => "Error. Please run 'cc' for a list of available commands and their corresponding usage"}
|
10
|
+
ERRORS = {'cli_arguments_exception' => "Error. Please run 'cc-cli' for a list of available commands and their corresponding usage"}
|
11
11
|
|
12
12
|
def self.parse args
|
13
13
|
unless Cc::Api::Parser::ArgumentsMapper::get_url(args[:action]).nil?
|
@@ -54,7 +54,7 @@ module Cc
|
|
54
54
|
when "catalog-categories"
|
55
55
|
{ :request => { :url => Cc::Api::Parser::ArgumentsMapper::get_url(args[:action])[:url] + "?page=#{res[:page]}" } }
|
56
56
|
when "store-products"
|
57
|
-
{ :request => { url: Cc::Api::Parser::ArgumentsMapper::get_url(args[:action])[:url].sub('
|
57
|
+
{ :request => { url: Cc::Api::Parser::ArgumentsMapper::get_url(args[:action])[:url].sub(':db', res[:store]) + "?page=#{res[:page]}" } }
|
58
58
|
else
|
59
59
|
nil
|
60
60
|
end
|
data/spec/explorer_spec.rb
CHANGED
@@ -220,13 +220,13 @@ describe Cc::Api::Explorer::CLI do
|
|
220
220
|
let(:expected_table_row) { ['ashnods_cylix', '0.0037', '']}
|
221
221
|
context "something is returned" do
|
222
222
|
before(:each) do
|
223
|
-
stub_request(:get, "https://abc
|
223
|
+
stub_request(:get, "https://abc:123@api.crystalcommerce.com/v1/stores/storename/products?page=2").
|
224
224
|
to_return(:status => 200, :body => STORE_PRODUCTS_RESPONSE, :headers => {"Content-Type" => "application/json"})
|
225
225
|
end
|
226
226
|
|
227
227
|
it "returns something if arguments are correct" do
|
228
228
|
printed = capture_stdout do
|
229
|
-
args = ["store", "products", "--
|
229
|
+
args = ["store", "products", "--store", "storename", "--page", 2]
|
230
230
|
options = Cc::Api::Explorer::CLI.start(args)
|
231
231
|
end
|
232
232
|
|
@@ -69,10 +69,9 @@ describe Cc::Api::Parser::ArgumentsParser do
|
|
69
69
|
|
70
70
|
context "store" do
|
71
71
|
context "products" do
|
72
|
-
let(:url) { "https://
|
73
|
-
let(:
|
74
|
-
let(:
|
75
|
-
let(:args) { { :action => "store-products", :params => { :token => token, :store => "arux", :page => 2 } } }
|
72
|
+
let(:url) { "https://api.crystalcommerce.com/v1/stores/arux/products?page=2" }
|
73
|
+
let(:expected_result) { { request: { url: url } } }
|
74
|
+
let(:args) { { :action => "store-products", :params => { :store => "arux", :page => 2 } } }
|
76
75
|
|
77
76
|
it_behaves_like "arguments parser returning expected result"
|
78
77
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cc-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neil Marion dela Cruz
|
@@ -192,4 +192,3 @@ test_files:
|
|
192
192
|
- spec/support/stdout_helper.rb
|
193
193
|
- spec/support/table_fields_matcher.rb
|
194
194
|
- spec/utils/utils_spec.rb
|
195
|
-
has_rdoc:
|