Permalink
Browse files

Strip comments and cleanup whitespace

  • Loading branch information...
maetl committed Mar 29, 2013
1 parent 5d93135 commit a1f9c9f70c982f409652ad0912d5afbc14827f1a
Showing with 15 additions and 123 deletions.
  1. +0 −1 lib/bigcommerce.rb
  2. +2 −37 lib/bigcommerce/api.rb
  3. +11 −83 lib/bigcommerce/connection.rb
  4. +2 −2 lib/bigcommerce/version.rb
View
@@ -1,6 +1,5 @@
require "cgi"
require "json"
-# require "net/https"
require 'rest-client'
require "uri"
require 'bigcommerce/api'
View
@@ -5,7 +5,6 @@ def initialize(configuration={})
@connection = Connection.new(configuration)
end
- # Added getter to ensure configuration is correct
def connection
@connection
end
@@ -30,8 +29,6 @@ def ca_file=(path)
@connection.ca_file = path
end
- # Returns the date formatted as
- # RFC 2822 string
def to_rfc2822(datetime)
datetime.strftime("%a, %d %b %Y %H:%M:%S %z")
end
@@ -40,8 +37,6 @@ def get_time
@connection.get '/time'
end
- #brands
-
def get_brands(options={})
@connection.get("/brands",options)
end
@@ -58,8 +53,6 @@ def update_brand(id,options={})
@connection.put("/brands/#{id}",options)
end
- #category
-
def get_categories(options={})
@connection.get("/categories",options)
end
@@ -80,8 +73,6 @@ def update_category(id,options={})
@connection.put("/categories/#{id}",options)
end
- #country
-
def get_countries(options={})
@connection.get("/countries",options)
end
@@ -90,7 +81,6 @@ def get_country(id)
@connection.get("/countries/#{id}",{})
end
- #states
def get_countries_states(options={})
@connection.get("/countries/states",options)
end
@@ -99,8 +89,6 @@ def get_countries_state(id,options={})
@connection.get("/countries/#{id}/states",{})
end
- #customers
-
def get_customers(options = {})
@connection.get("/customers",options)
end
@@ -109,8 +97,6 @@ def get_customer(id)
@connection.get('/customers/' + id.to_s,{})
end
- #customers/address
-
def get_customer_addresses(id,options = {})
@connection.get("/customers/#{id}/addresses",options)
end
@@ -119,8 +105,6 @@ def get_customer_address(customer_id,address_id)
@connection.get("/customers/#{customer_id}/addresses/#{address_id}",{})
end
- #options
-
def get_options(options={})
@connection.get("/options",options)
end
@@ -137,8 +121,6 @@ def update_option(id,options={})
@connection.put("/options/#{id}",options)
end
- #options/values
-
def get_options_values(options={})
@connection.get("/options/values",options)
end
@@ -192,8 +174,6 @@ def update_optionsets_option(id,options={})
@connection.put("/optionsets/options/#{id}",options)
end
- #order
-
def get_orders(options={})
@connection.get("/orders",options)
end
@@ -206,9 +186,6 @@ def update_order(id,options={})
@connection.put("/orders/#{id}",options)
end
-
-
- #order/coupons
def get_orders_coupons(id)
@connection.get("/orders/#{id}/coupons",{})
end
@@ -217,7 +194,6 @@ def get_orders_product(order_id,coupon_id)
@connection.get("/orders/#{order_id}/coupons/#{coupon_id}",{})
end
- #order/products
def get_orders_products(id)
@connection.get("/orders/#{id}/products",{})
end
@@ -226,7 +202,6 @@ def get_orders_product(order_id,product_id)
@connection.get("/orders/#{order_id}/products/#{product_id}",{})
end
- #order/shipments
def get_orders_shipments(id)
@connection.get("/orders/#{id}/shipments",{})
end
@@ -243,7 +218,6 @@ def update_orders_shipment(order_id,shipment_id,options={})
@connection.put("/orders/#{order_id}/shipments/#{shipment_id}",options)
end
- #orders/shippingaddresses
def get_orders_shippingaddresses(id)
@connection.get("/orders/#{id}/shippingaddresses",{})
end
@@ -252,7 +226,6 @@ def get_orders_shippingaddress(order_id,shippingaddress_id)
@connection.get("/orders/#{order_id}/shippingaddresses/#{shippingaddress_id}",{})
end
- #orderstatuses
def get_orderstatuses(options={})
@connection.get("/orderstatuses",options)
end
@@ -261,7 +234,6 @@ def get_orderstatuses(id)
@connection.get("/orderstatuses/#{id}",{})
end
- #products
def get_products(options={})
@connection.get("/products",options)
end
@@ -278,7 +250,6 @@ def update_products(id, options={})
@connection.put("/products/#{id}", options)
end
- #products/bulkdiscount
def get_products_discountrules(options={})
@connection.get("/products/discountrules",options)
end
@@ -287,7 +258,6 @@ def get_products_discountrule(product_id,discountrule_id)
@connection.get("/products/#{product_id}/discountrules/#{discountrule_id}",{})
end
- #products/configurablefields
def get_products_configurablefields(options={})
@connection.get("/products/configurablefields",options)
end
@@ -296,7 +266,6 @@ def get_products_configurablefield(product_id,configurable_field_id)
@connection.get("/products/#{product_id}/configurablefields/#{configurable_field_id}",{})
end
- #products/customfields
def get_products_customfields(options={})
@connection.get("/products/customfields",options)
end
@@ -305,7 +274,6 @@ def get_products_customfield(product_id,custom_field_id)
@connection.get("/products/#{product_id}/customfields/#{custom_field_id}",{})
end
- #products/images
def get_products_images(options={})
@connection.get("/products/images",options)
end
@@ -322,7 +290,6 @@ def update_products_image(product_id,image_id,options={})
@connection.put("/products/#{product_id}/images/#{image_id}",options)
end
- #products/options
def get_products_customfields(options={})
@connection.get("/products/options",options)
end
@@ -331,7 +298,6 @@ def get_products_option(product_id,option_id)
@connection.get("/products/#{product_id}/options/#{option_id}",{})
end
- #products/rules
def get_products_rules(options={})
@connection.get("/products/rules",options)
end
@@ -365,7 +331,6 @@ def update_products_sku(product_id,sku_id,options={})
@connection.put("/products/#{product_id}/skus/#{sku_id}",options)
end
- #products/videos
def get_products_videos(options={})
@connection.get("/products/videos",options)
end
@@ -381,11 +346,11 @@ def get_count(result)
end
def get_resource(result)
-
+ result
end
def get_collection(result)
-
+ result
end
end
@@ -68,92 +68,20 @@ def request(method, path, options,headers={})
end
begin
response = case method
- when :get then
- restclient.get :params => options, :accept => :json, :content_type => :json
- when :post then
- restclient.post(options.to_json, :content_type => :json, :accept => :json)
- when :put then
- restclient.put(options.to_json, :content_type => :json, :accept => :json)
- when :delete then
- restclient.delete
-
- end
+ when :get then
+ restclient.get :params => options, :accept => :json, :content_type => :json
+ when :post then
+ restclient.post(options.to_json, :content_type => :json, :accept => :json)
+ when :put then
+ restclient.put(options.to_json, :content_type => :json, :accept => :json)
+ when :delete then
+ restclient.delete
+ end
JSON.parse response
rescue => e
{"error"=>"Nothing to parse. Possibly no data?"}.to_json
end
-
end
-
- # def request(method, path, options = {})
- # #body, params = options.values_at(:body, :params)
- # #headers = options[:headers] || {}
-
- # headers = {}
- # uri = URI.parse(@configuration[:store_url] + '/api/v2' + path)
- # #param_string = hash_to_params(params) unless params.nil? || params.empty?
-
- # # unless (param_string.nil? || param_string.empty?)
- # # uri = URI.parse("#{url}?#{param_string}")
- # # else
- # # uri = URI.parse(url)
- # # end
-
- # http = Net::HTTP.new(uri.host, uri.port)
- # http.use_ssl = true
-
- # if @configuration.has_key?(:verify_peer) && @configuration[:verify_peer]
- # http.verify_mode = OpenSSL::SSL::VERIFY_PEER
- # else
- # http.verify_mode = OpenSSL::SSL::VERIFY_NONE
- # end
-
- # http.ca_file = @configuration[:ca_path] if @configuration.has_key?(:ca_path)
-
- # request = case method
- # when :get then
- # Net::HTTP::Get.new(uri.request_uri)
- # when :post then
- # Net::HTTP::Post.new(uri.request_uri)
- # when :put then
- # Net::HTTP::Put.new(uri.request_uri)
- # when :delete then
- # Net::HTTP::Delete.new(uri.request_uri)
- # end
-
- # request.basic_auth(@configuration[:username], @configuration[:api_key])
- # request.add_field 'Accept', 'application/json'
- # request.add_field 'Content-Type', 'application/json'
- # headers.each { |k,v| request.add_field(k, v) }
-
- # #add request body
- # case method
- # when :post then
- # request.set_form_data(options)
- # end
-
- # response = http.request(request)
-
- # return case response
- # when Net::HTTPSuccess, Net::HTTPRedirection
- # JSON.parse(response.body || "{}")
- # else
- # false
- # end
- # end
-
- # def hash_to_params(hash)
- # return nil if hash.nil? || hash.empty?
-
- # # convert the hash to URL params
- # return hash.map {|pair| pair.join("=")}.join("&")
-
-
- # end
- end
-
-
- # class HttpError < Exception
-
- # end
+
+ end
end
@@ -1,6 +1,6 @@
module Bigcommerce
- major = 1
- minor = 0
+ major = 0
+ minor = 9
patch = 0
VERSION = [major, minor, patch].join('.') unless defined? Bigcommerce::VERSION
end

0 comments on commit a1f9c9f

Please sign in to comment.