Class: Cc::Api::Explorer::CLI
- Inherits:
-
Thor
- Object
- Thor
- Cc::Api::Explorer::CLI
- Defined in:
- lib/cc/api/explorer.rb
Constant Summary collapse
- DEFAULT_COLS =
{ "market_data-products" => ["store_variant.store_name", "store_variant.qty", "store_variant.buy_price.money.currency"], "market_data-stores" => ["store.name", "store.state", "store.url"], "market_data-offers" => ["store.name", "buy_price.cents", "sell_price.cents"], "catalog-products" => ["name", "barcode", "weight"], "catalog-product_types" => ["name", "id", "default_weight"], "catalog-stores" => ["name", "postal_code", "url"], "catalog-categories" => ["name", "seoname", "description"], "store-products" => ["product.seoname", "product.weight", "product.description"] }
- DESC =
{ "cols" => "Columns to display to the output table. To determine the 'available columns' for a selected command use --available_cols", "available_cols" => "Output the available columns for output for a command", "offset" => "Offset of the starting row to be displayed. Nothing is displayed when out of bounds", "limit" => "Limit of rows to be displayed", "colw" => "Width of every column to be displayed", "colp" => "Padding of every cell to be displayed", "json" => "Prints the JSON response body instead", "id" => "Product ID", "skus" => "SKUs separated by ',' if more than one", "page" => "Page number of the response", "store" => "Store name (CrystalCommerce Client)", "csv" => "Print out the result into a csv file. Columns are separated by comma" }
Instance Method Summary collapse
Instance Method Details
#catalog(subcommand) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/cc/api/explorer.rb', line 87 def catalog(subcommand) case subcommand when "products" # { products : [ { ... } } args = {:action => "catalog-products", :params => { :page => [:page] || 1 } } perform(args) when "product_types" # { products : [ { ... } ] } args = {:action => "catalog-product_types", :params => { :page => [:page] || 1 } } perform(args) when "stores" # { stores : [ { ... } ] } args = {:action => "catalog-stores"} perform(args) when "categories" # { categories : [ { ... } ] } args = {:action => "catalog-categories", :params => { :page => [:page] || 1} } perform(args) else Cc::Api::Parser::ArgumentsParser.raise_cli_arguments_exception end end |
#market_data(subcommand) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/cc/api/explorer.rb', line 56 def market_data(subcommand) case subcommand when "products" # { product : { variants : { store_variants : [ { store_variant : { ... } } ] } } } args = {:action => "market_data-products", :params => {:id => [:id], :skus => [:skus].to_s.split(',') } } perform(args) when "stores" # { [ { store : { ... } } ] } args = {:action => "market_data-stores"} perform(args) when "offers" # { <PRODUCT ID> : [ { ... } ] } args = {:action => "market_data-offers", :params => {:id => [:id], :skus => [:skus].to_s.split(',') } } perform(args) else Cc::Api::Parser::ArgumentsParser.raise_cli_arguments_exception end end |
#store(subcommand) ⇒ Object
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/cc/api/explorer.rb', line 122 def store(subcommand) case subcommand when "products" # { paginated_collection : { entries : [ { product: { ... } } ] } } args = {:action => "store-products", :params => {:store => [:store], :page => [:page] || 1} } perform(args) else Cc::Api::Parser::ArgumentsParser.raise_cli_arguments_exception end end |