Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Strip comments and cleanup whitespace

  • Loading branch information...
commit a1f9c9f70c982f409652ad0912d5afbc14827f1a 1 parent 5d93135
Mark Rickerby authored
1  lib/bigcommerce.rb
... ...
@@ -1,6 +1,5 @@
1 1
 require "cgi"
2 2
 require "json"
3  
-# require "net/https"
4 3
 require 'rest-client'
5 4
 require "uri"
6 5
 require 'bigcommerce/api'
39  lib/bigcommerce/api.rb
@@ -5,7 +5,6 @@ def initialize(configuration={})
5 5
       @connection = Connection.new(configuration)
6 6
     end
7 7
 
8  
-    # Added getter to ensure configuration is correct
9 8
     def connection
10 9
       @connection
11 10
     end
@@ -30,8 +29,6 @@ def ca_file=(path)
30 29
       @connection.ca_file = path
31 30
     end
32 31
 
33  
-    # Returns the date formatted as
34  
-    # RFC 2822 string
35 32
     def to_rfc2822(datetime)
36 33
       datetime.strftime("%a, %d %b %Y %H:%M:%S %z")
37 34
     end
@@ -40,8 +37,6 @@ def get_time
40 37
       @connection.get '/time'
41 38
     end
42 39
 
43  
-    #brands
44  
-
45 40
     def get_brands(options={})
46 41
       @connection.get("/brands",options)
47 42
     end
@@ -58,8 +53,6 @@ def update_brand(id,options={})
58 53
        @connection.put("/brands/#{id}",options)
59 54
     end
60 55
 
61  
-    #category
62  
-
63 56
     def get_categories(options={})
64 57
        @connection.get("/categories",options)
65 58
     end
@@ -80,8 +73,6 @@ def update_category(id,options={})
80 73
        @connection.put("/categories/#{id}",options)
81 74
     end
82 75
 
83  
-    #country
84  
-
85 76
     def get_countries(options={})
86 77
       @connection.get("/countries",options)
87 78
     end
@@ -90,7 +81,6 @@ def get_country(id)
90 81
       @connection.get("/countries/#{id}",{})
91 82
     end
92 83
 
93  
-    #states
94 84
     def get_countries_states(options={})
95 85
       @connection.get("/countries/states",options)
96 86
     end
@@ -99,8 +89,6 @@ def get_countries_state(id,options={})
99 89
       @connection.get("/countries/#{id}/states",{})
100 90
     end
101 91
 
102  
-     #customers
103  
-
104 92
     def get_customers(options = {})
105 93
       @connection.get("/customers",options)
106 94
     end
@@ -109,8 +97,6 @@ def get_customer(id)
109 97
       @connection.get('/customers/' + id.to_s,{})
110 98
     end
111 99
 
112  
-     #customers/address
113  
-
114 100
     def get_customer_addresses(id,options = {})
115 101
       @connection.get("/customers/#{id}/addresses",options)
116 102
     end
@@ -119,8 +105,6 @@ def get_customer_address(customer_id,address_id)
119 105
       @connection.get("/customers/#{customer_id}/addresses/#{address_id}",{})
120 106
     end
121 107
 
122  
-    #options
123  
-
124 108
     def get_options(options={})
125 109
        @connection.get("/options",options)
126 110
     end
@@ -137,8 +121,6 @@ def update_option(id,options={})
137 121
       @connection.put("/options/#{id}",options)
138 122
     end
139 123
 
140  
-    #options/values
141  
-
142 124
     def get_options_values(options={})
143 125
        @connection.get("/options/values",options)
144 126
     end
@@ -192,8 +174,6 @@ def update_optionsets_option(id,options={})
192 174
       @connection.put("/optionsets/options/#{id}",options)
193 175
     end
194 176
 
195  
-    #order
196  
-
197 177
     def get_orders(options={})
198 178
       @connection.get("/orders",options)
199 179
     end
@@ -206,9 +186,6 @@ def update_order(id,options={})
206 186
       @connection.put("/orders/#{id}",options)
207 187
     end
208 188
 
209  
-   
210  
-
211  
-    #order/coupons
212 189
     def get_orders_coupons(id)
213 190
       @connection.get("/orders/#{id}/coupons",{})
214 191
     end
@@ -217,7 +194,6 @@ def get_orders_product(order_id,coupon_id)
217 194
       @connection.get("/orders/#{order_id}/coupons/#{coupon_id}",{})
218 195
     end
219 196
 
220  
-    #order/products
221 197
     def get_orders_products(id)
222 198
       @connection.get("/orders/#{id}/products",{})
223 199
     end
@@ -226,7 +202,6 @@ def get_orders_product(order_id,product_id)
226 202
       @connection.get("/orders/#{order_id}/products/#{product_id}",{})
227 203
     end
228 204
 
229  
-    #order/shipments
230 205
     def get_orders_shipments(id)
231 206
       @connection.get("/orders/#{id}/shipments",{})
232 207
     end
@@ -243,7 +218,6 @@ def update_orders_shipment(order_id,shipment_id,options={})
243 218
       @connection.put("/orders/#{order_id}/shipments/#{shipment_id}",options)
244 219
     end
245 220
 
246  
-    #orders/shippingaddresses
247 221
     def get_orders_shippingaddresses(id)
248 222
       @connection.get("/orders/#{id}/shippingaddresses",{})
249 223
     end
@@ -252,7 +226,6 @@ def get_orders_shippingaddress(order_id,shippingaddress_id)
252 226
       @connection.get("/orders/#{order_id}/shippingaddresses/#{shippingaddress_id}",{})
253 227
     end
254 228
 
255  
-    #orderstatuses
256 229
     def get_orderstatuses(options={})
257 230
       @connection.get("/orderstatuses",options)
258 231
     end
@@ -261,7 +234,6 @@ def get_orderstatuses(id)
261 234
       @connection.get("/orderstatuses/#{id}",{})
262 235
     end
263 236
 
264  
-    #products
265 237
     def get_products(options={})
266 238
       @connection.get("/products",options)
267 239
     end
@@ -278,7 +250,6 @@ def update_products(id, options={})
278 250
       @connection.put("/products/#{id}", options)
279 251
     end
280 252
     
281  
-    #products/bulkdiscount
282 253
     def get_products_discountrules(options={})
283 254
       @connection.get("/products/discountrules",options)
284 255
     end
@@ -287,7 +258,6 @@ def get_products_discountrule(product_id,discountrule_id)
287 258
       @connection.get("/products/#{product_id}/discountrules/#{discountrule_id}",{})
288 259
     end
289 260
 
290  
-    #products/configurablefields
291 261
     def get_products_configurablefields(options={})
292 262
       @connection.get("/products/configurablefields",options)
293 263
     end
@@ -296,7 +266,6 @@ def get_products_configurablefield(product_id,configurable_field_id)
296 266
       @connection.get("/products/#{product_id}/configurablefields/#{configurable_field_id}",{})
297 267
     end
298 268
 
299  
-    #products/customfields
300 269
     def get_products_customfields(options={})
301 270
       @connection.get("/products/customfields",options)
302 271
     end
@@ -305,7 +274,6 @@ def get_products_customfield(product_id,custom_field_id)
305 274
       @connection.get("/products/#{product_id}/customfields/#{custom_field_id}",{})
306 275
     end
307 276
 
308  
-    #products/images
309 277
     def get_products_images(options={})
310 278
       @connection.get("/products/images",options)
311 279
     end
@@ -322,7 +290,6 @@ def update_products_image(product_id,image_id,options={})
322 290
       @connection.put("/products/#{product_id}/images/#{image_id}",options)
323 291
     end
324 292
 
325  
-    #products/options
326 293
     def get_products_customfields(options={})
327 294
       @connection.get("/products/options",options)
328 295
     end
@@ -331,7 +298,6 @@ def get_products_option(product_id,option_id)
331 298
       @connection.get("/products/#{product_id}/options/#{option_id}",{})
332 299
     end
333 300
 
334  
-    #products/rules
335 301
     def get_products_rules(options={})
336 302
       @connection.get("/products/rules",options)
337 303
     end
@@ -365,7 +331,6 @@ def update_products_sku(product_id,sku_id,options={})
365 331
       @connection.put("/products/#{product_id}/skus/#{sku_id}",options)
366 332
     end
367 333
 
368  
-    #products/videos
369 334
     def get_products_videos(options={})
370 335
       @connection.get("/products/videos",options)
371 336
     end
@@ -381,11 +346,11 @@ def get_count(result)
381 346
     end
382 347
 
383 348
     def get_resource(result)
384  
-
  349
+      result
385 350
     end
386 351
 
387 352
     def get_collection(result)
388  
-
  353
+      result
389 354
     end
390 355
 
391 356
   end
94  lib/bigcommerce/connection.rb
@@ -68,92 +68,20 @@ def request(method, path, options,headers={})
68 68
       end
69 69
       begin
70 70
         response = case method
71  
-                    when :get then
72  
-                      restclient.get :params => options, :accept => :json, :content_type => :json
73  
-                    when :post then
74  
-                      restclient.post(options.to_json, :content_type => :json, :accept => :json)
75  
-                    when :put then
76  
-                      restclient.put(options.to_json, :content_type => :json, :accept => :json)
77  
-                    when :delete then
78  
-                      restclient.delete
79  
-                  
80  
-                    end
  71
+                   when :get then
  72
+                     restclient.get :params => options, :accept => :json, :content_type => :json
  73
+                   when :post then
  74
+                     restclient.post(options.to_json, :content_type => :json, :accept => :json)
  75
+                   when :put then
  76
+                     restclient.put(options.to_json, :content_type => :json, :accept => :json)
  77
+                   when :delete then
  78
+                     restclient.delete
  79
+                   end
81 80
         JSON.parse response
82 81
       rescue => e
83 82
          {"error"=>"Nothing to parse. Possibly no data?"}.to_json
84 83
       end
85  
-      
86 84
     end
87  
-
88  
-  #   def request(method, path, options = {})
89  
-  #     #body, params = options.values_at(:body, :params)
90  
-  #     #headers = options[:headers] || {}
91  
-
92  
-  #     headers = {}
93  
-  #     uri = URI.parse(@configuration[:store_url] + '/api/v2' + path)
94  
-  #     #param_string = hash_to_params(params) unless params.nil? || params.empty?
95  
-
96  
-  #     # unless (param_string.nil? || param_string.empty?)
97  
-  #     #   uri = URI.parse("#{url}?#{param_string}")
98  
-  #     # else
99  
-  #     #   uri = URI.parse(url)
100  
-  #     # end
101  
-
102  
-  #     http = Net::HTTP.new(uri.host, uri.port)
103  
-  #     http.use_ssl = true
104  
-
105  
-  #     if @configuration.has_key?(:verify_peer) && @configuration[:verify_peer]
106  
-  #       http.verify_mode = OpenSSL::SSL::VERIFY_PEER
107  
-  #     else
108  
-  #       http.verify_mode = OpenSSL::SSL::VERIFY_NONE
109  
-  #     end
110  
-
111  
-  #     http.ca_file = @configuration[:ca_path] if @configuration.has_key?(:ca_path)
112  
-
113  
-  #     request = case method
114  
-  #                 when :get then
115  
-  #                   Net::HTTP::Get.new(uri.request_uri)
116  
-  #                 when :post then
117  
-  #                   Net::HTTP::Post.new(uri.request_uri)
118  
-  #                 when :put then
119  
-  #                   Net::HTTP::Put.new(uri.request_uri)
120  
-  #                 when :delete then
121  
-  #                   Net::HTTP::Delete.new(uri.request_uri)
122  
-  #               end
123  
-
124  
-  #     request.basic_auth(@configuration[:username], @configuration[:api_key])
125  
-  #     request.add_field 'Accept', 'application/json'
126  
-  #     request.add_field 'Content-Type', 'application/json'
127  
-  #     headers.each { |k,v| request.add_field(k, v) }
128  
-
129  
-  #     #add request body
130  
-  #     case method
131  
-  #     when :post then
132  
-  #       request.set_form_data(options)
133  
-  #     end
134  
-
135  
-  #     response = http.request(request)
136  
-
137  
-  #     return case response
138  
-  #              when Net::HTTPSuccess, Net::HTTPRedirection
139  
-  #                JSON.parse(response.body || "{}")
140  
-  #              else
141  
-  #                false
142  
-  #            end
143  
-  #   end
144  
-
145  
-  #   def hash_to_params(hash)
146  
-  #     return nil if hash.nil? || hash.empty?
147  
-
148  
-  #     # convert the hash to URL params
149  
-  #     return hash.map {|pair| pair.join("=")}.join("&")
150  
-
151  
-
152  
-  #   end
153  
-   end
154  
-
155  
-
156  
-  # class HttpError < Exception
157  
-
158  
-  # end
  85
+ 
  86
+  end
159 87
 end
4  lib/bigcommerce/version.rb
... ...
@@ -1,6 +1,6 @@
1 1
 module Bigcommerce
2  
-  major = 1
3  
-  minor = 0
  2
+  major = 0
  3
+  minor = 9
4 4
   patch = 0
5 5
   VERSION = [major, minor, patch].join('.') unless defined? Bigcommerce::VERSION
6 6
 end

0 notes on commit a1f9c9f

Please sign in to comment.
Something went wrong with that request. Please try again.