gecko-ruby 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4615d6a4c9837beea8823b1857c462194aed5643
4
- data.tar.gz: 6f8af375fb425b612ed5b3ae8761733bf4da9912
3
+ metadata.gz: 5c081d1825735e5c7a065c5b594c27c7d2a89d35
4
+ data.tar.gz: 4f7866b500af81b44440665c0f42b891ef64088a
5
5
  SHA512:
6
- metadata.gz: 0f10cc383a8740107befd09b173cf91ba9ea80933ae544e18524f8588a6cf921be7713587ecd2068662704f0ff22273941cb9119aef850419a4eedf00ef25d37
7
- data.tar.gz: 500969a17050e07ee70ddb0c3182a7fa5a574f318df50221ccad1ebfb3e2287ab7f3813c945f8d0683b36fa23139bb42f32cb92d68412b7af6b52625337fd854
6
+ metadata.gz: 6729e2175db7b875c369e5a4dab15fda98b321379ae66233c2a21ce3aeb79c1a443b90f71b446993e2bc57202d82c5b8848c15e47feae1690cfcf8726c2776a3
7
+ data.tar.gz: 3b378afaecefb0f1107e0c9af8f862abd91893fb810510cb0cab478af76d4170556b101e77c6f3e1521b80c87a563c698a3056646cded857eb5d1d12c8e30df8
@@ -1,5 +1,10 @@
1
+ ## 0.0.8 (2015-09-10)
2
+ - Fetch VariantLocation#committed_stock as committed
3
+ - Make image uploading work
4
+
1
5
  ## 0.0.7 (2015-03-17)
2
6
  - Fix issue with Order#tax_override
7
+ - Support sideloaded records without a hack
3
8
 
4
9
  ## 0.0.6 (2015-03-17)
5
10
  - Add `Gecko::Record::PaymentTerm`
data/README.md CHANGED
@@ -31,6 +31,16 @@ products = client.Product.where(q: "Gecko")
31
31
  #=> [<Gecko::Record::Product id=1 name="Geckotron">, <Gecko::Record::Product id=3 name="Green Gecko">]
32
32
  ```
33
33
 
34
+ ## Basic Usage Using a Privileged Access Token
35
+
36
+ ```ruby
37
+ client = Gecko::Client.new(CLIENT_ID, CLIENT_SECRET)
38
+ client.authorize_from_existing(PRIVILEGED_ACCESS_TOKEN, nil, nil)
39
+
40
+ products = client.Product.where(q: "Gecko")
41
+ #=> [<Gecko::Record::Product id=1 name="Geckotron">, <Gecko::Record::Product id=3 name="Green Gecko">]
42
+ ```
43
+
34
44
  ## Finding Records
35
45
 
36
46
  #### Basic finders
@@ -146,6 +146,8 @@ module Gecko
146
146
  # @example
147
147
  # client.Product.fetch(12)
148
148
  #
149
+ # @param [Integer] id ID of record
150
+ #
149
151
  # @return [Gecko::Record::Base] if a record was found
150
152
  # @return [nil] if no record was found
151
153
  #
@@ -170,6 +172,7 @@ module Gecko
170
172
  #
171
173
  # @api private
172
174
  def parse_records(json)
175
+ parse_sideloaded_records(json)
173
176
  extract_collection(json).map do |record_json|
174
177
  instantiate_and_register_record(record_json)
175
178
  end
@@ -227,6 +230,18 @@ module Gecko
227
230
  end
228
231
  end
229
232
 
233
+ # Instantiates a record from it's JSON representation and registers
234
+ # it into the identity map
235
+ #
236
+ # @return [Gecko::Record::Base]
237
+ #
238
+ # @api private
239
+ def instantiate_and_register_record(record_json)
240
+ record = model_class.new(@client, record_json)
241
+ register_record(record)
242
+ record
243
+ end
244
+
230
245
  private
231
246
 
232
247
  # Returns the json key for a record adapter
@@ -262,18 +277,6 @@ module Gecko
262
277
  Gecko::Record.const_get(@model_name)
263
278
  end
264
279
 
265
- # Instantiates a record from it's JSON representation and registers
266
- # it into the identity map
267
- #
268
- # @return [Gecko::Record::Base]
269
- #
270
- # @api private
271
- def instantiate_and_register_record(record_json)
272
- record = model_class.new(@client, record_json)
273
- register_record(record)
274
- record
275
- end
276
-
277
280
  # Registers a record into the identity map
278
281
  #
279
282
  # @return [Gecko::Record::Base]
@@ -339,6 +342,24 @@ module Gecko
339
342
  @pagination = JSON.parse(headers["x-pagination"]) if headers["x-pagination"]
340
343
  end
341
344
 
345
+ # Parse and instantiate sideloaded records
346
+ #
347
+ # @api private
348
+ def parse_sideloaded_records(json)
349
+ json.each do |record_type, records|
350
+ next if record_type == "meta"
351
+ next if record_type == @model_name.to_s
352
+
353
+ record_class = record_type.singularize.classify
354
+ next unless Gecko::Record.const_defined?(record_class)
355
+ adapter = @client.adapter_for(record_class)
356
+
357
+ records.each do |record_json|
358
+ adapter.instantiate_and_register_record(record_json)
359
+ end
360
+ end
361
+ end
362
+
342
363
  # Makes a request to the API.
343
364
  #
344
365
  # @param [Symbol] verb the HTTP request method
@@ -26,17 +26,6 @@ module Gecko
26
26
  end
27
27
 
28
28
  class FulfillmentAdapter < BaseAdapter
29
- # Parse sideloaded FulfillmentLineItems into the Identity map
30
- # instead of refetching them
31
- def parse_records(json)
32
- records = super
33
- parse_line_items(json) if json['fulfillment_line_items']
34
- records
35
- end
36
-
37
- def parse_line_items(json)
38
- @client.FulfillmentLineItem.parse_records(json)
39
- end
40
29
  end
41
30
  end
42
31
  end
@@ -8,10 +8,12 @@ module Gecko
8
8
  belongs_to :variant
9
9
  belongs_to :uploader, class_name: "User"
10
10
  attribute :name, String
11
+ attribute :url, String
11
12
  attribute :position, Integer
12
- attribute :base_path, String
13
- attribute :file_name, String
14
- attribute :versions, Array[String]
13
+ attribute :base_path, String, readonly: true
14
+ attribute :file_name, String, readonly: true
15
+ attribute :versions, Array[String], readonly: true
16
+
15
17
  # attribute :image_processing, Boolean
16
18
 
17
19
  # URL for image
@@ -23,6 +25,12 @@ module Gecko
23
25
  #
24
26
  # @api public
25
27
  def url(size = :full)
28
+ super() || build_url(size)
29
+ end
30
+
31
+ private
32
+
33
+ def build_url(size)
26
34
  if size == :full
27
35
  file_path = file_name
28
36
  else
@@ -33,6 +41,11 @@ module Gecko
33
41
  end
34
42
 
35
43
  class ImageAdapter < BaseAdapter
44
+ private
45
+
46
+ def update_record(_record)
47
+ raise NotImplementedError
48
+ end
36
49
  end
37
50
  end
38
51
  end
@@ -7,9 +7,11 @@ module Gecko
7
7
  include Virtus.model
8
8
  include Gecko::Helpers::SerializationHelper
9
9
  attribute :location_id, Integer
10
- attribute :committed_stock, BigDecimal
10
+ attribute :committed, BigDecimal
11
11
  attribute :stock_on_hand, BigDecimal
12
12
  attribute :bin_location, String
13
+
14
+ alias_method :committed_stock, :committed
13
15
  end
14
16
 
15
17
  class VariantPrice
@@ -1,3 +1,3 @@
1
1
  module Gecko
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
@@ -0,0 +1,84 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.lvh.me:3000/products?_include=variants&limit=5
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Gecko/0.0.5 OAuth2/1.0.0 Faraday/0.9.1 Ruby/2.1.5
12
+ Authorization:
13
+ - Bearer 57b0f2b0a4ffe949eef65796429f7089e967dc6f4b197f60e387f03e44afd27c
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Thu, 12 Mar 2015 09:39:55 GMT
25
+ Status:
26
+ - 200 OK
27
+ Connection:
28
+ - close
29
+ X-Frame-Options:
30
+ - ALLOW-FROM https://login.bigcommerce.com
31
+ X-Rate-Limit-Limit:
32
+ - '300'
33
+ X-Rate-Limit-Remaining:
34
+ - '299'
35
+ X-Rate-Limit-Reset:
36
+ - '1426153200'
37
+ X-Pagination:
38
+ - '{"total_records":5,"total_pages":1,"first_page":true,"last_page":true,"out_of_bounds":false,"offset":0}'
39
+ Link:
40
+ - <http://api.lvh.me:3000/ajax/products?limit=5&page=1&include=variants>; rel="last"
41
+ Content-Type:
42
+ - application/json; charset=utf-8
43
+ Etag:
44
+ - '"e627dcd7fcdb904e75f5f34e99d52769"'
45
+ Cache-Control:
46
+ - max-age=0, private, must-revalidate
47
+ X-Request-Id:
48
+ - 2d51871d-5944-41b9-839d-6d1c0560866d
49
+ X-Runtime:
50
+ - '0.588396'
51
+ Transfer-Encoding:
52
+ - chunked
53
+ body:
54
+ encoding: UTF-8
55
+ string: '{"variants":[{"id":457,"created_at":"2015-02-26T09:54:05.506Z","updated_at":"2015-03-05T10:38:54.377Z","product_id":104,"default_ledger_account_id":null,"buy_price":null,"committed_stock":"1","incoming_stock":"0","composite":false,"description":null,"is_online":false,"keep_selling":false,"last_cost_price":"111.0","manage_stock":true,"max_online":null,"moving_average_cost":"111","name":"Gecko
56
+ Guitar X1","online_ordering":false,"opt1":"Default","opt2":null,"opt3":null,"position":1,"product_name":"Gecko
57
+ Guitar X1","product_status":"active","product_type":"Acoustic Electric","retail_price":null,"sellable":true,"sku":null,"status":"active","stock_on_hand":"111","supplier_code":null,"taxable":true,"upc":null,"weight":null,"wholesale_price":null,"image_ids":[],"variant_prices":[],"locations":[{"location_id":2,"stock_on_hand":"111","committed":"1","incoming":null,"bin_location":null,"reorder_point":null}],"prices":{},"stock_levels":{"2":"111.0"},"committed_stock_levels":{"2":"1.0"},"incoming_stock_levels":{}},{"id":39,"created_at":"2015-02-11T09:02:36.850Z","updated_at":"2015-02-11T09:39:00.988Z","product_id":13,"default_ledger_account_id":null,"buy_price":"900.0","committed_stock":"10","incoming_stock":"0","composite":false,"description":null,"is_online":false,"keep_selling":false,"last_cost_price":"1000.0","manage_stock":true,"max_online":null,"moving_average_cost":"1000","name":"Hummingbird
58
+ Pro 2","online_ordering":true,"opt1":"1","opt2":null,"opt3":null,"position":3,"product_name":"Hummingbird","product_status":"active","product_type":"Acoustic
59
+ Electric","retail_price":"2500.0","sellable":true,"sku":null,"status":"active","stock_on_hand":"10","supplier_code":null,"taxable":true,"upc":null,"weight":null,"wholesale_price":"1200.0","image_ids":[15],"variant_prices":[{"price_list_id":"buy","value":"900.0"},{"price_list_id":"retail","value":"2500.0"},{"price_list_id":"wholesale","value":"1200.0"}],"locations":[{"location_id":2,"stock_on_hand":"10","committed":"10","incoming":null,"bin_location":null,"reorder_point":null}],"prices":{"buy":"900.0","retail":"2500.0","wholesale":"1200.0"},"stock_levels":{"2":"10.0"},"committed_stock_levels":{"2":"10.0"},"incoming_stock_levels":{}},{"id":38,"created_at":"2015-02-11T06:42:14.748Z","updated_at":"2015-02-11T09:01:12.979Z","product_id":13,"default_ledger_account_id":null,"buy_price":"2000.0","committed_stock":"0","incoming_stock":"0","composite":false,"description":null,"is_online":false,"keep_selling":false,"last_cost_price":"1000.0","manage_stock":true,"max_online":null,"moving_average_cost":"1000","name":"Hummingbird
60
+ Pro","online_ordering":true,"opt1":null,"opt2":null,"opt3":null,"position":2,"product_name":"Hummingbird","product_status":"active","product_type":"Acoustic
61
+ Electric","retail_price":"2000.0","sellable":true,"sku":null,"status":"active","stock_on_hand":"1000","supplier_code":null,"taxable":true,"upc":null,"weight":null,"wholesale_price":"1000.0","image_ids":[],"variant_prices":[{"price_list_id":"buy","value":"2000.0"},{"price_list_id":"retail","value":"2000.0"},{"price_list_id":"wholesale","value":"1000.0"}],"locations":[{"location_id":2,"stock_on_hand":"1000","committed":null,"incoming":null,"bin_location":null,"reorder_point":null}],"prices":{"buy":"2000.0","retail":"2000.0","wholesale":"1000.0"},"stock_levels":{"2":1000.0},"committed_stock_levels":{},"incoming_stock_levels":{}},{"id":37,"created_at":"2015-02-11T04:40:52.557Z","updated_at":"2015-02-11T09:05:16.322Z","product_id":13,"default_ledger_account_id":null,"buy_price":"100.0","committed_stock":"5","incoming_stock":"0","composite":false,"description":null,"is_online":false,"keep_selling":false,"last_cost_price":"1000.0","manage_stock":true,"max_online":null,"moving_average_cost":"1000","name":"Hummingbird","online_ordering":true,"opt1":"Default","opt2":null,"opt3":null,"position":1,"product_name":"Hummingbird","product_status":"active","product_type":"Acoustic
62
+ Electric","retail_price":"1200.0","sellable":true,"sku":"","status":"active","stock_on_hand":"105","supplier_code":null,"taxable":true,"upc":null,"weight":null,"wholesale_price":"600.0","image_ids":[],"variant_prices":[{"price_list_id":"buy","value":"100.0"},{"price_list_id":"retail","value":"1200.0"},{"price_list_id":"wholesale","value":"600.0"}],"locations":[{"location_id":2,"stock_on_hand":"105","committed":"5","incoming":null,"bin_location":null,"reorder_point":null}],"prices":{"buy":"100.0","retail":"1200.0","wholesale":"600.0"},"stock_levels":{"2":"105.0"},"committed_stock_levels":{"2":"5.0"},"incoming_stock_levels":{}},{"id":36,"created_at":"2015-02-10T06:08:31.340Z","updated_at":"2015-02-12T02:13:08.518Z","product_id":12,"default_ledger_account_id":null,"buy_price":"700.0","committed_stock":"0","incoming_stock":"0","composite":false,"description":null,"is_online":false,"keep_selling":false,"last_cost_price":"1000.0","manage_stock":true,"max_online":null,"moving_average_cost":"1000","name":"Epiphone
63
+ EJ 200 CE","online_ordering":true,"opt1":"Default","opt2":null,"opt3":null,"position":1,"product_name":"Epiphone
64
+ EJ 200 CE","product_status":"active","product_type":"Acoustic Electric","retail_price":"1500.0","sellable":true,"sku":"","status":"active","stock_on_hand":"1111","supplier_code":null,"taxable":true,"upc":null,"weight":null,"wholesale_price":"900.0","image_ids":[9],"variant_prices":[{"price_list_id":"buy","value":"700.0"},{"price_list_id":"retail","value":"1500.0"},{"price_list_id":"wholesale","value":"900.0"}],"locations":[{"location_id":2,"stock_on_hand":"1111","committed":null,"incoming":null,"bin_location":null,"reorder_point":null}],"prices":{"buy":"700.0","retail":"1500.0","wholesale":"900.0"},"stock_levels":{"2":1111.0},"committed_stock_levels":{},"incoming_stock_levels":{}},{"id":40,"created_at":"2015-02-18T04:11:56.125Z","updated_at":"2015-02-23T04:01:21.475Z","product_id":8,"default_ledger_account_id":null,"buy_price":"2222.0","committed_stock":"0","incoming_stock":"0","composite":false,"description":null,"is_online":false,"keep_selling":false,"last_cost_price":"2222.0","manage_stock":true,"max_online":null,"moving_average_cost":"2222","name":null,"online_ordering":true,"opt1":"M","opt2":null,"opt3":null,"position":2,"product_name":"AJ
65
+ 300","product_status":"active","product_type":"Acoustic Guitar","retail_price":"2222.0","sellable":true,"sku":null,"status":"active","stock_on_hand":"19","supplier_code":null,"taxable":true,"upc":null,"weight":null,"wholesale_price":"2222.0","image_ids":[],"variant_prices":[{"price_list_id":"buy","value":"2222.0"},{"price_list_id":"retail","value":"2222.0"},{"price_list_id":"wholesale","value":"2222.0"}],"locations":[{"location_id":2,"stock_on_hand":"19","committed":null,"incoming":null,"bin_location":null,"reorder_point":null}],"prices":{"buy":"2222.0","retail":"2222.0","wholesale":"2222.0"},"stock_levels":{"2":19.0},"committed_stock_levels":{},"incoming_stock_levels":{}},{"id":41,"created_at":"2015-02-18T04:11:56.279Z","updated_at":"2015-02-20T05:31:14.070Z","product_id":8,"default_ledger_account_id":null,"buy_price":"2222.0","committed_stock":"0","incoming_stock":"0","composite":false,"description":null,"is_online":false,"keep_selling":false,"last_cost_price":"2222.0","manage_stock":true,"max_online":null,"moving_average_cost":"2222","name":"AJ
66
+ 300 B","online_ordering":false,"opt1":"L","opt2":null,"opt3":null,"position":3,"product_name":"AJ
67
+ 300","product_status":"active","product_type":"Acoustic Guitar","retail_price":"2222.0","sellable":true,"sku":null,"status":"active","stock_on_hand":"11","supplier_code":null,"taxable":true,"upc":null,"weight":null,"wholesale_price":"2222.0","image_ids":[],"variant_prices":[{"price_list_id":"buy","value":"2222.0"},{"price_list_id":"retail","value":"2222.0"},{"price_list_id":"wholesale","value":"2222.0"}],"locations":[{"location_id":2,"stock_on_hand":"11","committed":null,"incoming":null,"bin_location":null,"reorder_point":null}],"prices":{"buy":"2222.0","retail":"2222.0","wholesale":"2222.0"},"stock_levels":{"2":11.0},"committed_stock_levels":{},"incoming_stock_levels":{}},{"id":24,"created_at":"2015-01-26T02:28:49.992Z","updated_at":"2015-02-20T04:58:11.742Z","product_id":8,"default_ledger_account_id":null,"buy_price":"2000.0","committed_stock":"3","incoming_stock":"0","composite":false,"description":null,"is_online":false,"keep_selling":false,"last_cost_price":"2000.0","manage_stock":true,"max_online":null,"moving_average_cost":"2000","name":"AJ
68
+ 300","online_ordering":true,"opt1":"Default","opt2":null,"opt3":null,"position":1,"product_name":"AJ
69
+ 300","product_status":"active","product_type":"Acoustic Guitar","retail_price":"3000.0","sellable":true,"sku":"","status":"active","stock_on_hand":"29","supplier_code":null,"taxable":true,"upc":null,"weight":null,"wholesale_price":"2200.0","image_ids":[3],"variant_prices":[{"price_list_id":"buy","value":"2000.0"},{"price_list_id":"retail","value":"3000.0"},{"price_list_id":"wholesale","value":"2200.0"},{"price_list_id":"1","value":null}],"locations":[{"location_id":2,"stock_on_hand":"29","committed":"3","incoming":null,"bin_location":null,"reorder_point":null}],"prices":{"buy":"2000.0","retail":"3000.0","wholesale":"2200.0","1":null},"stock_levels":{"2":"29.0"},"committed_stock_levels":{"2":"3.0"},"incoming_stock_levels":{}},{"id":23,"created_at":"2015-01-26T02:28:13.702Z","updated_at":"2015-02-09T03:03:20.021Z","product_id":7,"default_ledger_account_id":null,"buy_price":"1000.0","committed_stock":"4","incoming_stock":"0","composite":false,"description":null,"is_online":false,"keep_selling":false,"last_cost_price":"1000.0","manage_stock":true,"max_online":null,"moving_average_cost":"1000","name":"Gibson
70
+ J200","online_ordering":true,"opt1":"Default","opt2":null,"opt3":null,"position":1,"product_name":"Gibson
71
+ J200","product_status":"active","product_type":"Acoustic Guitar","retail_price":"1500.0","sellable":true,"sku":"","status":"active","stock_on_hand":"100","supplier_code":null,"taxable":true,"upc":null,"weight":null,"wholesale_price":"1100.0","image_ids":[],"variant_prices":[{"price_list_id":"buy","value":"1000.0"},{"price_list_id":"retail","value":"1500.0"},{"price_list_id":"wholesale","value":"1100.0"}],"locations":[{"location_id":2,"stock_on_hand":"100","committed":"4","incoming":null,"bin_location":null,"reorder_point":null}],"prices":{"buy":"1000.0","retail":"1500.0","wholesale":"1100.0"},"stock_levels":{"2":"100.0"},"committed_stock_levels":{"2":"4.0"},"incoming_stock_levels":{}}],"products":[{"id":104,"created_at":"2015-02-26T09:54:05.453Z","updated_at":"2015-02-26T09:54:05.453Z","brand":null,"description":"","image_url":null,"name":"Gecko
72
+ Guitar X1","opt1":"Size","opt2":null,"opt3":null,"product_type":"Acoustic
73
+ Electric","quantity":"110","search_cache":"Gecko Guitar X1","status":"active","supplier":null,"tags":null,"vendor":null,"variant_ids":[457]},{"id":13,"created_at":"2015-02-11T04:40:52.175Z","updated_at":"2015-02-11T04:40:52.175Z","brand":"Epiphone","description":null,"image_url":"https://tradegecko-development-images.s3.amazonaws.com/uploads/variant_image/image/15/thumbnail_Screen_Shot_2015-02-10_at_12.53.34_pm.png","name":"Hummingbird","opt1":"Size","opt2":null,"opt3":null,"product_type":"Acoustic
74
+ Electric","quantity":"1100","search_cache":"Hummingbird Pro 2 Hummingbird
75
+ Pro Hummingbird","status":"active","supplier":"Epiphone","tags":null,"vendor":"Epiphone","variant_ids":[39,38,37]},{"id":12,"created_at":"2015-02-10T06:08:31.185Z","updated_at":"2015-02-10T06:08:31.185Z","brand":"Epiphone","description":null,"image_url":"https://tradegecko-development-images.s3.amazonaws.com/uploads/variant_image/image/9/thumbnail_testimage00001.png","name":"Epiphone
76
+ EJ 200 CE","opt1":"Size","opt2":null,"opt3":null,"product_type":"Acoustic
77
+ Electric","quantity":"1111","search_cache":"Epiphone EJ 200 CE","status":"active","supplier":"Epiphone","tags":null,"vendor":"Epiphone","variant_ids":[36]},{"id":8,"created_at":"2015-01-26T02:28:49.958Z","updated_at":"2015-02-09T09:09:00.338Z","brand":"Gibson","description":null,"image_url":"https://tradegecko-development-images.s3.amazonaws.com/uploads/variant_image/image/3/thumbnail_Screen_Shot_2015-02-10_at_12.42.58_pm.png","name":"AJ
78
+ 300","opt1":"Size","opt2":null,"opt3":null,"product_type":"Acoustic Guitar","quantity":"56","search_cache":"AJ
79
+ 300 B AJ 300","status":"active","supplier":"Gibson","tags":"acoustic","vendor":"Gibson","variant_ids":[40,41,24]},{"id":7,"created_at":"2015-01-26T02:28:13.510Z","updated_at":"2015-02-09T09:18:51.078Z","brand":"Gibson","description":null,"image_url":null,"name":"Gibson
80
+ J200","opt1":"Size","opt2":null,"opt3":null,"product_type":"Acoustic Guitar","quantity":"96","search_cache":"Gibson
81
+ J200","status":"active","supplier":"Gibson","tags":"Acoustic Premium,acoustic","vendor":"Gibson","variant_ids":[23]}],"meta":{"total":5}}'
82
+ http_version:
83
+ recorded_at: Thu, 12 Mar 2015 09:39:55 GMT
84
+ recorded_with: VCR 2.9.3
@@ -11,4 +11,8 @@ class Gecko::Record::ImageAdapterTest < Minitest::Test
11
11
  def test_initializes_adapter
12
12
  assert_instance_of(Gecko::Record::ImageAdapter, @client.Image)
13
13
  end
14
+
15
+ # Updating images via the API is currently unsupported
16
+ undef :test_saving_existing_invalid_record
17
+ undef :test_saving_existing_record
14
18
  end
@@ -3,10 +3,12 @@ require 'test_helper'
3
3
  class Gecko::Record::ProductAdapterTest < Minitest::Test
4
4
  include TestingAdapter
5
5
  include SharedAdapterExamples
6
+ include SharedSideloadedDataParsingExamples
6
7
 
7
8
  let(:adapter) { @client.Product }
8
9
  let(:plural_name) { 'products' }
9
10
  let(:record_class) { Gecko::Record::Product }
11
+ let(:children) { ["variants"] }
10
12
 
11
13
  def test_initializes_adapter
12
14
  assert_instance_of(Gecko::Record::ProductAdapter, @client.Product)
@@ -32,8 +32,10 @@ class Gecko::VariantTest < Minitest::Test
32
32
 
33
33
  def test_variant_locations
34
34
  json = {locations: [
35
- {location_id: 1, stock_on_hand: "12.50", committed_stock: "0", bin_location: "AB-123"},
35
+ { location_id: 1, stock_on_hand: "12.50",
36
+ committed: "0", bin_location: "AB-123" },
36
37
  ]}
38
+
37
39
  locations = record_class.new(client, json).locations
38
40
  assert_instance_of(Gecko::Record::Variant::VariantLocation, locations.first)
39
41
  assert_equal(1, locations[0].location_id)
@@ -0,0 +1,17 @@
1
+ module SharedSideloadedDataParsingExamples
2
+ def test_adapter_sideloaded_data_parsing
3
+ VCR.use_cassette(plural_name + '_sideloaded') do
4
+
5
+ collection = adapter.where(limit: 5, _include: children.join(","))
6
+
7
+ children.each do |child|
8
+ child_adapter = @client.adapter_for(child.singularize.classify)
9
+
10
+ identity_map = child_adapter.instance_variable_get(:@identity_map)
11
+ child_collection = collection.flat_map { |record| record.send(child) }
12
+
13
+ assert_equal child_collection, identity_map.values
14
+ end
15
+ end
16
+ end
17
+ end
@@ -9,6 +9,7 @@ require 'timecop'
9
9
  require 'support/let'
10
10
  require 'support/shared_adapter_examples'
11
11
  require 'support/shared_record_examples'
12
+ require 'support/shared_sideloaded_data_parsing_examples'
12
13
  require 'support/testing_adapter'
13
14
  require 'support/vcr_support'
14
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gecko-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bradley Priest
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-17 00:00:00.000000000 Z
11
+ date: 2015-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -274,6 +274,7 @@ files:
274
274
  - test/fixtures/vcr_cassettes/products_count.yml
275
275
  - test/fixtures/vcr_cassettes/products_new_invalid.yml
276
276
  - test/fixtures/vcr_cassettes/products_new_valid.yml
277
+ - test/fixtures/vcr_cassettes/products_sideloaded.yml
277
278
  - test/fixtures/vcr_cassettes/purchase_order_line_items.yml
278
279
  - test/fixtures/vcr_cassettes/purchase_order_line_items_count.yml
279
280
  - test/fixtures/vcr_cassettes/purchase_orders.yml
@@ -332,6 +333,7 @@ files:
332
333
  - test/support/let.rb
333
334
  - test/support/shared_adapter_examples.rb
334
335
  - test/support/shared_record_examples.rb
336
+ - test/support/shared_sideloaded_data_parsing_examples.rb
335
337
  - test/support/testing_adapter.rb
336
338
  - test/support/vcr_support.rb
337
339
  - test/test_helper.rb
@@ -391,6 +393,7 @@ test_files:
391
393
  - test/fixtures/vcr_cassettes/products_count.yml
392
394
  - test/fixtures/vcr_cassettes/products_new_invalid.yml
393
395
  - test/fixtures/vcr_cassettes/products_new_valid.yml
396
+ - test/fixtures/vcr_cassettes/products_sideloaded.yml
394
397
  - test/fixtures/vcr_cassettes/purchase_order_line_items.yml
395
398
  - test/fixtures/vcr_cassettes/purchase_order_line_items_count.yml
396
399
  - test/fixtures/vcr_cassettes/purchase_orders.yml
@@ -449,6 +452,7 @@ test_files:
449
452
  - test/support/let.rb
450
453
  - test/support/shared_adapter_examples.rb
451
454
  - test/support/shared_record_examples.rb
455
+ - test/support/shared_sideloaded_data_parsing_examples.rb
452
456
  - test/support/testing_adapter.rb
453
457
  - test/support/vcr_support.rb
454
458
  - test/test_helper.rb