cc-cli 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OGUwZWI3ZTk1NTBjOWNiMGZlMjEyYmIwYTY2YzEzMjQwNzNjMTFiYg==
5
- data.tar.gz: !binary |-
6
- ZjQxMzZkODk4ZDZjYjZjZmEyYjhkMjE0ODk3NWM2ODNkNjgyOWQxOA==
2
+ SHA1:
3
+ metadata.gz: e9da8373affb1432638dd806deab62e18222243f
4
+ data.tar.gz: b1a3ed80586614d6be73c75c3b2f752ba89984ce
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- OGE5MTE4NGE0YTMyZDNkYTBkYjUzNzc4ODRkMzhhN2E5NzI0YTM3ZWUxYzA3
10
- NGQ2YzAxOTU0OGU2YTEzNjllMDg3MWVmZDRjN2YzNjkzOWJhNjljYjk0MDZk
11
- MDlmMTk3MWQ2MDExN2EwZDJmMzcyMzk1NGNkZmNmNTg1YTQ3ODk=
12
- data.tar.gz: !binary |-
13
- MmFlNzQ5YmZhYWIxODk3MjZiYTUyMWRiZTI4NWFjZmY3OWQxMDJhNTA5NjNm
14
- MTQ2N2QzNDhjMmMwYzVhNmY3M2VlMDQzY2NhOTBlNDY0ZmRkMjc4MzgwZGYy
15
- NGY2YTE1NTZjYmMxZDNiODdlODMwNDYzYTViMDA2Yzg0ZGM3NmU=
6
+ metadata.gz: a490ff560e7a256591d922de611a787b250746ea795ef2505b1f58935ded1fb261fe7ad124bae47c2623db40767c8c2c1c95a2f192a1579ed61afb364ba53012
7
+ data.tar.gz: de3eb0699c52dc71d09d204cbaeb121bd33fd95b992dc467d0678d7e8169d6d3b06a154f490838e493a2618a36776824f96a271f328307094d48e9db2ebd9d10
data/.gitignore CHANGED
@@ -16,4 +16,5 @@ test/version_tmp
16
16
  tmp
17
17
  *.sw*
18
18
  null.txt
19
- *.gem
19
+ *.gem
20
+ .env
data/README.md CHANGED
@@ -4,15 +4,7 @@ This is a command line client for exploring CrystalCommerce APIs
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'cc-cli', :git => "git@github.com:crystalcommerce/cc-cli.git"
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as (not yet available as of the moment):
7
+ Install it:
16
8
 
17
9
  $ gem install cc-cli
18
10
 
@@ -23,7 +15,7 @@ To view help:
23
15
  $ cc-cli
24
16
 
25
17
  The license key pair `<ssologin>` and `<key>` are basically just basic auth username and password respectively.
26
- To obtain a license key, contact: contact: Jerad Ellison or call (206) 274-7437 Ext. 3.
18
+ To obtain a license key, contact: Jerad Ellison or call (206) 274-7437 Ext. 3.
27
19
 
28
20
  Add these lines in your ~/.bashrc (linux) or ~/.profile (mac) file:
29
21
 
@@ -45,7 +37,7 @@ These are the available commands:
45
37
 
46
38
  $ cc-cli catalog [products] | [product_types] | [stores] | [categories]
47
39
  $ cc-cli help [COMMND]
48
- $ cc-cli lattice [products --id <PRODUCT ID> --skus <PRODUCT SKUS separated by ','>] | [offers --id <PRODUCT ID> --skus <PRODUCT SKUS separated by ','>] | [stores]
40
+ $ cc-cli market_data [products --id <PRODUCT ID> --skus <PRODUCT SKUS separated by ','>] | [offers --id <PRODUCT ID> --skus <PRODUCT SKUS separated by ','>] | [stores]
49
41
  $ cc-cli store [products --token <access token> --store <store name>]
50
42
 
51
43
  To choose columns/json keys to display:
data/circle.yml CHANGED
@@ -1,5 +1,8 @@
1
1
  test:
2
2
  override:
3
+ - rvm use --default 1.9.1
4
+ - bundle install
5
+ - bundle exec rspec
3
6
  - rvm use --default 1.9.3
4
7
  - bundle install
5
8
  - bundle exec rspec
@@ -8,4 +11,4 @@ test:
8
11
  - bundle exec rspec
9
12
  - rvm use --default 2.1.1
10
13
  - bundle install
11
- - bundle exec rspec
14
+ - bundle exec rspec
@@ -1,12 +1,12 @@
1
- lattice:
1
+ market_data:
2
2
  products:
3
- url: https://api.crystalcommerce.com/v1/lattice/products
3
+ url: https://api.crystalcommerce.com/v1/market_data/products
4
4
  target_key_chain: "product.variants.FIRST.variant.store_variants"
5
5
  stores:
6
- url: https://api.crystalcommerce.com/v1/lattice/stores
6
+ url: https://api.crystalcommerce.com/v1/market_data/stores
7
7
  target_key_chain: ""
8
8
  offers:
9
- url: https://api.crystalcommerce.com/v1/lattice/offers
9
+ url: https://api.crystalcommerce.com/v1/market_data/offers
10
10
  method: POST
11
11
  target_key_chain: "PRODUCT_ID"
12
12
  catalog:
@@ -15,9 +15,9 @@ module Cc
15
15
  class CLI < Thor
16
16
  DEFAULT_COLS =
17
17
  {
18
- "lattice-products" => ["store_variant.store_name", "store_variant.qty", "store_variant.buy_price.money.currency"],
19
- "lattice-stores" => ["store.name", "store.state", "store.url"],
20
- "lattice-offers" => ["store.name", "buy_price.cents", "sell_price.cents"],
18
+ "market_data-products" => ["store_variant.store_name", "store_variant.qty", "store_variant.buy_price.money.currency"],
19
+ "market_data-stores" => ["store.name", "store.state", "store.url"],
20
+ "market_data-offers" => ["store.name", "buy_price.cents", "sell_price.cents"],
21
21
  "catalog-products" => ["name", "barcode", "weight"],
22
22
  "catalog-product_types" => ["name", "id", "default_weight"],
23
23
  "catalog-stores" => ["name", "postal_code", "url"],
@@ -52,21 +52,21 @@ module Cc
52
52
  option :json, :type => :boolean, :desc => DESC["json"]
53
53
  option :id, :desc => DESC["id"]
54
54
  option :skus, :desc => DESC["skus"]
55
- desc "lattice [products --id <PRODUCT ID> --skus <PRODUCT SKUS separated by ','>] | [offers --id <PRODUCT ID> --skus <PRODUCT SKUS separated by comma>] | [stores]",
55
+ desc "market_data [products --id <PRODUCT ID> --skus <PRODUCT SKUS separated by ','>] | [offers --id <PRODUCT ID> --skus <PRODUCT SKUS separated by comma>] | [stores]",
56
56
  "The Market Data APIs track the Prices, Quantities, and similar data. It also indicates which stores in the CrystalCommerce in-network currently has those products for sale."
57
- def lattice(subcommand)
57
+ def market_data(subcommand)
58
58
  case subcommand
59
59
  when "products"
60
60
  # { product : { variants : { store_variants : [ { store_variant : { ... } } ] } } }
61
- args = {:action => "lattice-products", :params => {:id => options[:id], :skus => options[:skus].to_s.split(',') } }
61
+ args = {:action => "market_data-products", :params => {:id => options[:id], :skus => options[:skus].to_s.split(',') } }
62
62
  perform(args)
63
63
  when "stores"
64
64
  # { [ { store : { ... } } ] }
65
- args = {:action => "lattice-stores"}
65
+ args = {:action => "market_data-stores"}
66
66
  perform(args)
67
67
  when "offers"
68
68
  # { <PRODUCT ID> : [ { ... } ] }
69
- args = {:action => "lattice-offers", :params => {:id => options[:id], :skus => options[:skus].to_s.split(',') } }
69
+ args = {:action => "market_data-offers", :params => {:id => options[:id], :skus => options[:skus].to_s.split(',') } }
70
70
  perform(args)
71
71
  else
72
72
  Cc::Api::Parser::ArgumentsParser.raise_cli_arguments_exception
@@ -1,7 +1,7 @@
1
1
  module Cc
2
2
  module Api
3
3
  module Explorer
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
7
  end
@@ -3,10 +3,10 @@ require 'httparty'
3
3
  module Cc
4
4
  module Api
5
5
  module Http
6
- class ServerProblemException < Exception
6
+ class ServerProblemException < StandardError
7
7
  end
8
8
 
9
- class UnauthorizedAccessException < Exception
9
+ class UnauthorizedAccessException < StandardError
10
10
  end
11
11
 
12
12
  class HttpRequestor
@@ -3,7 +3,7 @@ require 'cc/api/parser/arguments_mapper'
3
3
  module Cc
4
4
  module Api
5
5
  module Parser
6
- class CLIArgumentsException < Exception
6
+ class CLIArgumentsException < StandardError
7
7
  end
8
8
 
9
9
  class ArgumentsParser
@@ -12,7 +12,7 @@ module Cc
12
12
  def self.parse args
13
13
  unless Cc::Api::Parser::ArgumentsMapper::get_url(args[:action]).nil?
14
14
  if res = Cc::Api::Parser::ArgumentsMapper.map(args)
15
- self.build_action_url args, res
15
+ self.build_action_url args, res
16
16
  else
17
17
  self.raise_cli_arguments_exception
18
18
  end
@@ -33,17 +33,17 @@ module Cc
33
33
 
34
34
  def self.build_action_url args, res
35
35
  case args[:action]
36
- when "lattice-products"
36
+ when "market_data-products"
37
37
  #TODO fix this
38
38
  { :request => { url: Cc::Api::Parser::ArgumentsMapper::get_url(args[:action])[:url] + "/#{res[:id]}?" + res[:skus].collect{|x| "skus[]=#{x}" }.join('&') } }
39
- when "lattice-stores"
39
+ when "market_data-stores"
40
40
  { :request => Cc::Api::Parser::ArgumentsMapper::get_url(args[:action]) }
41
- when "lattice-offers"
42
- { :request => {
41
+ when "market_data-offers"
42
+ { :request => {
43
43
  url: Cc::Api::Parser::ArgumentsMapper::get_url(args[:action])[:url],
44
44
  body: {"search" => {"skus" => {"#{res[:id]}" => res[:skus].collect{|x| x.to_s }}}},
45
45
  method: Cc::Api::Parser::ArgumentsMapper::get_url(args[:action])[:method]
46
- }
46
+ }
47
47
  }
48
48
  when "catalog-products"
49
49
  { :request => { :url => Cc::Api::Parser::ArgumentsMapper::get_url(args[:action])[:url] + "?page=#{res[:page]}" } }
@@ -1,7 +1,7 @@
1
1
  module Cc
2
2
  module Api
3
3
  module Util
4
- class LicenseKeysException < Exception
4
+ class LicenseKeysException < StandardError
5
5
  end
6
6
 
7
7
  class ConfigReader
@@ -16,8 +16,7 @@ module Cc
16
16
  def get_keys
17
17
  login = ENV.fetch("CC_API_LOGIN")
18
18
  key = ENV.fetch("CC_API_KEY")
19
- raise_license_key_exception if login.empty?
20
- raise_license_key_exception if key.empty?
19
+ raise_license_key_exception if login.empty? || key.empty?
21
20
  [login, key]
22
21
  rescue KeyError
23
22
  raise_license_key_exception
@@ -10,7 +10,7 @@ describe Cc::Api::Explorer::CLI do
10
10
 
11
11
  let(:cc) { cc = Cc::Api::Explorer::CLI.new }
12
12
 
13
- context "lattice" do
13
+ context "market_data" do
14
14
  let(:skus) { ["123abc", "456def"] }
15
15
 
16
16
  context "products" do
@@ -20,17 +20,17 @@ describe Cc::Api::Explorer::CLI do
20
20
 
21
21
  context "something is returned" do
22
22
  before(:each) do
23
- stub_request(:get, "https://abc:123@api.crystalcommerce.com/v1/lattice/products/#{id}?skus[]=#{skus[0]}").
24
- to_return(:status => 200, :body => LATTICE_PRODUCTS_RESPONSE, :headers => {"Content-Type" => "application/json"})
23
+ stub_request(:get, "https://abc:123@api.crystalcommerce.com/v1/market_data/products/#{id}?skus[]=#{skus[0]}").
24
+ to_return(:status => 200, :body => MARKET_DATA_PRODUCTS_RESPONSE, :headers => {"Content-Type" => "application/json"})
25
25
 
26
- stub_request(:get, "https://abc:123@api.crystalcommerce.com/v1/lattice/products/#{id}?skus[]=#{skus[0]}&skus[]=#{skus[1]}").
27
- to_return(:status => 200, :body => LATTICE_PRODUCTS_RESPONSE, :headers => {"Content-Type" => "application/json"})
26
+ stub_request(:get, "https://abc:123@api.crystalcommerce.com/v1/market_data/products/#{id}?skus[]=#{skus[0]}&skus[]=#{skus[1]}").
27
+ to_return(:status => 200, :body => MARKET_DATA_PRODUCTS_RESPONSE, :headers => {"Content-Type" => "application/json"})
28
28
  end
29
29
 
30
30
  it "returns something if arguments are correct" do
31
31
 
32
32
  printed = capture_stdout do
33
- args = ["lattice", "products", "--id", "123", "--skus", "123abc"]
33
+ args = ["market_data", "products", "--id", "123", "--skus", "123abc"]
34
34
  options = Cc::Api::Explorer::CLI.start(args)
35
35
  end
36
36
 
@@ -40,7 +40,7 @@ describe Cc::Api::Explorer::CLI do
40
40
  it "returns something if arguments are correct for multiple skus" do
41
41
 
42
42
  printed = capture_stdout do
43
- args = ["lattice", "products", "--id", "123", "--skus", skus.join(',')]
43
+ args = ["market_data", "products", "--id", "123", "--skus", skus.join(',')]
44
44
  options = Cc::Api::Explorer::CLI.start(args)
45
45
  end
46
46
 
@@ -51,7 +51,7 @@ describe Cc::Api::Explorer::CLI do
51
51
  context "something is not returned" do
52
52
  it "returns an exception if arguments are not correct" do
53
53
  printed = capture_stdout do
54
- args = ["lattice", "products", "wrong", "arguments"]
54
+ args = ["market_data", "products", "wrong", "arguments"]
55
55
  options = Cc::Api::Explorer::CLI.start(args)
56
56
  end
57
57
 
@@ -59,11 +59,11 @@ describe Cc::Api::Explorer::CLI do
59
59
  end
60
60
 
61
61
  it "returns blank if blank variants was returned" do
62
- stub_request(:get, "https://abc:123@api.crystalcommerce.com/v1/lattice/products/#{id}?skus[]=#{skus[0]}&skus[]=#{skus[1]}").
62
+ stub_request(:get, "https://abc:123@api.crystalcommerce.com/v1/market_data/products/#{id}?skus[]=#{skus[0]}&skus[]=#{skus[1]}").
63
63
  to_return(:status => 200, :body => '{"product":{"product_id":201750,"variants":[]}}', :headers => {"Content-Type" => "application/json"})
64
64
 
65
65
  printed = capture_stdout do
66
- args = ["lattice", "products", "--id", "123", "--skus", skus.join(',')]
66
+ args = ["market_data", "products", "--id", "123", "--skus", skus.join(',')]
67
67
  options = Cc::Api::Explorer::CLI.start(args)
68
68
  end
69
69
 
@@ -71,12 +71,12 @@ describe Cc::Api::Explorer::CLI do
71
71
  end
72
72
 
73
73
  it "returns blank if nil json was returned" do
74
- stub_request(:get, "https://abc:123@api.crystalcommerce.com/v1/lattice/products/#{id}?skus[]=#{skus[0]}&skus[]=#{skus[1]}").
74
+ stub_request(:get, "https://abc:123@api.crystalcommerce.com/v1/market_data/products/#{id}?skus[]=#{skus[0]}&skus[]=#{skus[1]}").
75
75
  to_return(:status => 200, :body => nil, :headers => {"Content-Type" => "application/json"})
76
76
 
77
77
 
78
78
  printed = capture_stdout do
79
- args = ["latticeproducts", "--id", "123", "--skus", skus.join(',')]
79
+ args = ["market_dataproducts", "--id", "123", "--skus", skus.join(',')]
80
80
  options = Cc::Api::Explorer::CLI.start(args)
81
81
  end
82
82
 
@@ -89,11 +89,11 @@ describe Cc::Api::Explorer::CLI do
89
89
  let(:expected_table_row) { ["Lettie Traffanstedt'", "", ""]}
90
90
  context "something is returned" do
91
91
  it "returns something" do
92
- stub_request(:get, "https://abc:123@api.crystalcommerce.com/v1/lattice/stores").
93
- to_return(:status => 200, :body => LATTICE_STORES_RESPONSE, :headers => {"Content-Type" => "application/json"})
92
+ stub_request(:get, "https://abc:123@api.crystalcommerce.com/v1/market_data/stores").
93
+ to_return(:status => 200, :body => MARKET_DATA_STORES_RESPONSE, :headers => {"Content-Type" => "application/json"})
94
94
 
95
95
  printed = capture_stdout do
96
- args = ["lattice", "stores"]
96
+ args = ["market_data", "stores"]
97
97
  options = Cc::Api::Explorer::CLI.start(args)
98
98
  end
99
99
 
@@ -103,11 +103,11 @@ describe Cc::Api::Explorer::CLI do
103
103
 
104
104
  context "something is not returned" do
105
105
  it "returns nothing" do
106
- stub_request(:get, "https://abc:123@api.crystalcommerce.com/v1/lattice/stores").
106
+ stub_request(:get, "https://abc:123@api.crystalcommerce.com/v1/market_data/stores").
107
107
  to_return(:status => 200, :body => nil, :headers => {"Content-Type" => "application/json"})
108
108
 
109
109
  printed = capture_stdout do
110
- args = ["lattice", "stores"]
110
+ args = ["market_data", "stores"]
111
111
  options = Cc::Api::Explorer::CLI.start(args)
112
112
  end
113
113
 
@@ -121,12 +121,12 @@ describe Cc::Api::Explorer::CLI do
121
121
  context "something is returned" do
122
122
  it "returns something" do
123
123
  pending
124
- stub_request(:post, "https://abc:123@api.crystalcommerce.com/v1/lattice/offers").
124
+ stub_request(:post, "https://abc:123@api.crystalcommerce.com/v1/market_data/offers").
125
125
  with(:body => "{\"search\":{\"skus\":{\"201750\":[\"123abc\",\"456def\"]}}}", :headers => {"Content-Type" => "application/json"}).
126
- to_return(:status => 200, :body => LATTICE_OFFERS_RESPONSE, :headers => {"Content-Type" => "application/json"})
126
+ to_return(:status => 200, :body => MARKET_DATA_OFFERS_RESPONSE, :headers => {"Content-Type" => "application/json"})
127
127
 
128
128
  #printed = capture_stdout do
129
- args = ["lattice", "offers", "--id", "201750", "--skus", skus.join(',')]
129
+ args = ["market_data", "offers", "--id", "201750", "--skus", skus.join(',')]
130
130
  options = Cc::Api::Explorer::CLI.start(args)
131
131
  #end
132
132
 
@@ -8,12 +8,12 @@ describe Cc::Api::Http::HttpRequestor do
8
8
  end
9
9
 
10
10
  context "returns valid JSON response for a post request" do
11
- let(:param) { {request: { url: "https://abc:123@api.crystalcommerce.com/v1/lattice/offers", :body=>{"search"=>{"skus"=>{"201750"=>["123abc", "456def"]}}}, method: "POST"} } }
11
+ let(:param) { {request: { url: "https://abc:123@api.crystalcommerce.com/v1/market_data/offers", :body=>{"search"=>{"skus"=>{"201750"=>["123abc", "456def"]}}}, method: "POST"} } }
12
12
 
13
13
  it "returns valid JSON response for a post request" do
14
- stub_request(:post, "https://abc:123@api.crystalcommerce.com/v1/lattice/offers").
14
+ stub_request(:post, "https://abc:123@api.crystalcommerce.com/v1/market_data/offers").
15
15
  with(:body => "{\"search\":{\"skus\":{\"201750\":[\"123abc\",\"456def\"]}}}", :headers => {"Content-Type" => "application/json"}).
16
- to_return(:status => 200, :body => LATTICE_OFFERS_RESPONSE, :headers => {"Content-Type" => "application/json"})
16
+ to_return(:status => 200, :body => MARKET_DATA_OFFERS_RESPONSE, :headers => {"Content-Type" => "application/json"})
17
17
 
18
18
  result = subject.request_for_json param
19
19
  result.should_not eq nil
@@ -22,7 +22,7 @@ describe Cc::Api::Http::HttpRequestor do
22
22
  end
23
23
 
24
24
  context "raises error" do
25
- let(:param) { {request: { url: "https://abc:123@api.crystalcommerce.com/v1/lattice/offers", :body=>{"search"=>{"skus"=>{"201750"=>["123abc", "456def"]}}}, method: "POST"} } }
25
+ let(:param) { {request: { url: "https://abc:123@api.crystalcommerce.com/v1/market_data/offers", :body=>{"search"=>{"skus"=>{"201750"=>["123abc", "456def"]}}}, method: "POST"} } }
26
26
 
27
27
  it "if license keys are not set properly" do
28
28
  Cc::Api::Util::ConfigReader.stub(:license).and_raise(Cc::Api::Util::LicenseKeysException)
@@ -32,7 +32,7 @@ describe Cc::Api::Http::HttpRequestor do
32
32
  end
33
33
 
34
34
  it "if not enough privileges" do
35
- stub_request(:post, "https://abc:123@api.crystalcommerce.com/v1/lattice/offers").
35
+ stub_request(:post, "https://abc:123@api.crystalcommerce.com/v1/market_data/offers").
36
36
  with(:body => "{\"search\":{\"skus\":{\"201750\":[\"123abc\",\"456def\"]}}}", :headers => {"Content-Type" => "application/json"}).
37
37
  to_return(:status => 401, :body => "", :headers => {"Content-Type" => "application/json"})
38
38
 
@@ -42,7 +42,7 @@ describe Cc::Api::Http::HttpRequestor do
42
42
  end
43
43
 
44
44
  it "if there's a server error" do
45
- stub_request(:post, "https://abc:123@api.crystalcommerce.com/v1/lattice/offers").
45
+ stub_request(:post, "https://abc:123@api.crystalcommerce.com/v1/market_data/offers").
46
46
  with(:body => "{\"search\":{\"skus\":{\"201750\":[\"123abc\",\"456def\"]}}}", :headers => {"Content-Type" => "application/json"}).
47
47
  to_return(:status => 500, :body => "", :headers => {"Content-Type" => "application/json"})
48
48
 
@@ -3,23 +3,23 @@ require 'spec_helper'
3
3
  describe Cc::Api::Parser::ArgumentsMapper do
4
4
  describe "map" do
5
5
  let(:rand) { "123" }
6
- context "lattice" do
6
+ context "market_data" do
7
7
  context "products" do
8
- let(:args) { {:action => "lattice-products", :params => { :id => rand, :skus => [rand] } } }
8
+ let(:args) { {:action => "market_data-products", :params => { :id => rand, :skus => [rand] } } }
9
9
  let(:wrong_args) { {:action => "this", :is => "a", :wrong => "argument" } }
10
10
 
11
11
  it_behaves_like "arguments mapper returning json with id and skus"
12
12
  end
13
13
 
14
14
  context "stores" do
15
- let(:args) { { :action => "lattice-stores" } }
15
+ let(:args) { { :action => "market_data-stores" } }
16
16
 
17
17
  it_behaves_like "arguments mapper returning blank json"
18
18
  end
19
19
 
20
20
  context "offers" do
21
21
  let(:rand) { "123" }
22
- let(:args) { { :action => "lattice-offers", :params => { :id => rand, :skus => [rand] } } }
22
+ let(:args) { { :action => "market_data-offers", :params => { :id => rand, :skus => [rand] } } }
23
23
 
24
24
  it "matches the args and creates a json object that maps the args" do
25
25
  res = Cc::Api::Parser::ArgumentsMapper.map args
@@ -7,27 +7,27 @@ describe Cc::Api::Parser::ArgumentsParser do
7
7
  end
8
8
 
9
9
  describe "parse" do
10
- context "lattice" do
11
- let(:url) { "https://api.crystalcommerce.com/v1/lattice/" }
10
+ context "market_data" do
11
+ let(:url) { "https://api.crystalcommerce.com/v1/market_data/" }
12
12
  let(:rand) { "123" }
13
13
 
14
14
  context "products" do
15
15
  let(:expected_result) { {request: {url: url + "products/" + rand + "?skus[]=" + rand } } }
16
- let(:args) { { :action => "lattice-products", :params => { :id => rand, :skus => [ rand ] } } }
16
+ let(:args) { { :action => "market_data-products", :params => { :id => rand, :skus => [ rand ] } } }
17
17
 
18
18
  it_behaves_like "arguments parser returning expected result"
19
19
  end
20
20
 
21
21
  context "stores" do
22
22
  let(:expected_result) { {request: { url: url + "stores", :target_key_chain => "" } } }
23
- let(:args) { {:action => "lattice-stores"} }
23
+ let(:args) { {:action => "market_data-stores"} }
24
24
 
25
25
  it_behaves_like "arguments parser returning expected result"
26
26
  end
27
27
 
28
28
  context "offers" do
29
29
  let(:expected_result) { {request: { url: url + "offers", :body=>{"search"=>{"skus"=>{"123"=>["123"]}}}, method: "POST"} } }
30
- let(:args) { {:action => "lattice-offers", :params => { :id => rand, :skus => [rand] } } }
30
+ let(:args) { {:action => "market_data-offers", :params => { :id => rand, :skus => [rand] } } }
31
31
 
32
32
  it_behaves_like "arguments parser returning expected result"
33
33
  end
@@ -4,11 +4,11 @@ require 'json'
4
4
  describe Cc::Api::Parser::JsonParser do
5
5
  context "'vanilla' reduce" do
6
6
  let(:product_id) { nil }
7
- context "lattice" do
7
+ context "market_data" do
8
8
  context "products" do
9
- let(:json_response) { LATTICE_PRODUCTS_RESPONSE }
9
+ let(:json_response) { MARKET_DATA_PRODUCTS_RESPONSE }
10
10
  let(:blank_json_response) {'{"product":{"product_id":123,"variants":[]}}'}
11
- let(:action) { "lattice-products" }
11
+ let(:action) { "market_data-products" }
12
12
  let(:chosen_columns) { ["store_variant.sku", "store_variant.store_name", "store_variant.store_business_name", "store_variant.sell_price.money.cents"] }
13
13
 
14
14
  it_behaves_like "json parser"
@@ -17,18 +17,18 @@ describe Cc::Api::Parser::JsonParser do
17
17
 
18
18
  context "offers" do
19
19
  let(:product_id) { "201750" }
20
- let(:json_response) { LATTICE_OFFERS_RESPONSE }
20
+ let(:json_response) { MARKET_DATA_OFFERS_RESPONSE }
21
21
  let(:blank_json_response) {'{"201750" : []}'}
22
- let(:action) { "lattice-offers" }
22
+ let(:action) { "market_data-offers" }
23
23
  let(:chosen_columns) { ["buy_price.cents", "qty", "product_url", "inventory_qty"] }
24
24
 
25
25
  it_behaves_like "json parser"
26
26
  end
27
27
 
28
28
  context "stores" do
29
- let(:json_response) { LATTICE_STORES_RESPONSE }
29
+ let(:json_response) { MARKET_DATA_STORES_RESPONSE }
30
30
  let(:blank_json_response) {'[]'}
31
- let(:action) { "lattice-stores" }
31
+ let(:action) { "market_data-stores" }
32
32
  let(:chosen_columns) { ["store.id", "store.name", "store.is_active", "store.country"] }
33
33
 
34
34
  it_behaves_like "json parser"
@@ -9,12 +9,12 @@ require 'pry'
9
9
  def suppress_stdouts config #need to suppress command_line_reporter's output
10
10
  original_stderr = $stderr
11
11
  original_stdout = $stdout
12
- config.before(:all) do
12
+ config.before(:all) do
13
13
  # Redirect stderr and stdout
14
14
  $stderr = File.new(File.join(File.dirname(__FILE__), 'dev', 'null.txt'), 'w')
15
15
  $stdout = File.new(File.join(File.dirname(__FILE__), 'dev', 'null.txt'), 'w')
16
16
  end
17
- config.after(:all) do
17
+ config.after(:all) do
18
18
  $stderr = original_stderr
19
19
  $stdout = original_stdout
20
20
  end
@@ -36,14 +36,12 @@ RSpec.configure do |config|
36
36
 
37
37
  #suppress_stdouts config
38
38
 
39
- LATTICE_PRODUCTS_RESPONSE = IO.read("spec/dummy_data/lattice_products.json") # sample json response
40
- LATTICE_STORES_RESPONSE = IO.read("spec/dummy_data/lattice_stores.json") # sample json response
41
- LATTICE_OFFERS_RESPONSE = IO.read("spec/dummy_data/lattice_offers.json") # sample json response
42
- CATALOG_PRODUCTS_RESPONSE = IO.read("spec/dummy_data/catalog_products.json") # sample json response
43
- CATALOG_PRODUCT_TYPES_RESPONSE = IO.read("spec/dummy_data/catalog_product_types.json") # sample json response
44
- CATALOG_STORES_RESPONSE = IO.read("spec/dummy_data/catalog_stores.json") # sample json response
45
- CATALOG_CATEGORIES_RESPONSE = IO.read("spec/dummy_data/catalog_categories.json") # sample json response
46
- STORE_PRODUCTS_RESPONSE = IO.read("spec/dummy_data/store_products.json") # sample json response
39
+ MARKET_DATA_PRODUCTS_RESPONSE = File.read("spec/dummy_data/market_data_products.json") # sample json response
40
+ MARKET_DATA_STORES_RESPONSE = File.read("spec/dummy_data/market_data_stores.json") # sample json response
41
+ MARKET_DATA_OFFERS_RESPONSE = File.read("spec/dummy_data/market_data_offers.json") # sample json response
42
+ CATALOG_PRODUCTS_RESPONSE = File.read("spec/dummy_data/catalog_products.json") # sample json response
43
+ CATALOG_PRODUCT_TYPES_RESPONSE = File.read("spec/dummy_data/catalog_product_types.json") # sample json response
44
+ CATALOG_STORES_RESPONSE = File.read("spec/dummy_data/catalog_stores.json") # sample json response
45
+ CATALOG_CATEGORIES_RESPONSE = File.read("spec/dummy_data/catalog_categories.json") # sample json response
46
+ STORE_PRODUCTS_RESPONSE = File.read("spec/dummy_data/store_products.json") # sample json response
47
47
  end
48
-
49
-
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Marion dela Cruz
@@ -9,90 +9,90 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-15 00:00:00.000000000 Z
12
+ date: 2014-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: command_line_reporter
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ! '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ! '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: httparty
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ! '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ! '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: thor
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ! '>='
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ! '>='
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: bundler
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ~>
60
+ - - "~>"
61
61
  - !ruby/object:Gem::Version
62
62
  version: '1.5'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ~>
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '1.5'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rake
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ! '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ! '>='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rspec
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ! '>='
88
+ - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ! '>='
95
+ - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  description: This is a command line client for exploring CrystalCommerce APIs
@@ -103,8 +103,8 @@ executables:
103
103
  extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
- - .gitignore
107
- - .rspec
106
+ - ".gitignore"
107
+ - ".rspec"
108
108
  - Gemfile
109
109
  - Guardfile
110
110
  - LICENSE.txt
@@ -127,9 +127,9 @@ files:
127
127
  - spec/dummy_data/catalog_product_types.json
128
128
  - spec/dummy_data/catalog_products.json
129
129
  - spec/dummy_data/catalog_stores.json
130
- - spec/dummy_data/lattice_offers.json
131
- - spec/dummy_data/lattice_products.json
132
- - spec/dummy_data/lattice_stores.json
130
+ - spec/dummy_data/market_data_offers.json
131
+ - spec/dummy_data/market_data_products.json
132
+ - spec/dummy_data/market_data_stores.json
133
133
  - spec/dummy_data/store_products.json
134
134
  - spec/explorer_spec.rb
135
135
  - spec/http/http_requestor_spec.rb
@@ -155,12 +155,12 @@ require_paths:
155
155
  - lib
156
156
  required_ruby_version: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - ! '>='
158
+ - - ">="
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  requirements:
163
- - - ! '>='
163
+ - - ">="
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0'
166
166
  requirements: []
@@ -174,9 +174,9 @@ test_files:
174
174
  - spec/dummy_data/catalog_product_types.json
175
175
  - spec/dummy_data/catalog_products.json
176
176
  - spec/dummy_data/catalog_stores.json
177
- - spec/dummy_data/lattice_offers.json
178
- - spec/dummy_data/lattice_products.json
179
- - spec/dummy_data/lattice_stores.json
177
+ - spec/dummy_data/market_data_offers.json
178
+ - spec/dummy_data/market_data_products.json
179
+ - spec/dummy_data/market_data_stores.json
180
180
  - spec/dummy_data/store_products.json
181
181
  - spec/explorer_spec.rb
182
182
  - spec/http/http_requestor_spec.rb
@@ -192,3 +192,4 @@ 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: