Class: EPlat::Mapping::Bigcommerce::V3::Product::Variant

Inherits:
EPlat::Mapping::Base show all
Defined in:
lib/e_plat/mapping/bigcommerce/v_3/product/variant.rb,
lib/e_plat/mapping/bigcommerce/v_3/product/variant/option_value.rb

Defined Under Namespace

Classes: OptionValue

Constant Summary

Constants inherited from EPlat::Mapping::Base

EPlat::Mapping::Base::DEFAULT_VALUES

Instance Attribute Summary

Attributes inherited from EPlat::Mapping::Base

#resource, #virtual_collection

Instance Method Summary collapse

Methods inherited from EPlat::Mapping::Base

#aliases, #e_plat_key_to, #initialize, #inspect, #keys_aliased_to_native_keys, #mappable_keys, #mappings, #native_key_to, #native_setter, #to_e_plat_keys, #to_native_keys, #via_native_attributes_where_possible, virtual_collection

Methods included from RequestBodyRoot

#include_root_in_request_body?

Constructor Details

This class inherits a constructor from EPlat::Mapping::Base

Instance Method Details

#native_attribute_aliasesObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/e_plat/mapping/bigcommerce/v_3/product/variant.rb', line 46

def native_attribute_aliases
	super.concat([
		{
			existing_entry: {native_key:   "id", 	e_plat_key: "id"}
		},
		{
			existing_entry: {native_key:   "price", 	e_plat_key: "price"}
		},
		{
			existing_entry: {native_key:   "sku", 		 e_plat_key: "sku"}
		},
		{
			existing_entry: {native_key:   "product_id", e_plat_key: "product_id"}
		},
		{
			alias_attribute: {native_key: "gtin", e_plat_key: "title",
				custom_e_plat_getter: "-> (value) {
					option_values&.map(&:label)&.join(' ').to_s
				}",
				custom_native_setter: "-> (value) {
					if value && self.option_values.count == 1
						self.option_values.first.label = value
						self.option_values;
					else;
						warn 'Can not set title on variant with multiple option values';
					end
				}"
			}
		},
		{
			alias_attribute: {native_key:  "option_values", e_plat_key: "option1", 
				custom_e_plat_getter: "-> (option_values) { 
					if option_values;
						option_values.first.label;
					end
				}",
				custom_native_setter: "-> (option_value) { 
					if option_values;
						self.option_values.first.label = option_value;
						self.option_values;
					end
				}" 
			}
		},
		{
			existing_entry: {native_key:   "weight",		 e_plat_key: "weight"}
		},
		{
			alias_attribute: {native_key:   "inventory_level", e_plat_key: "inventory_quantity"}
		}
	])
end

#native_attributesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/e_plat/mapping/bigcommerce/v_3/product/variant.rb', line 14

def native_attributes
	super.concat([
		"id",
		"product_id",
		"sku",
		"sku_id",
		"price",
		"calculated_price",
		"sale_price",
		"retail_price",
		"map_price",
		"weight",
		"calculated_weight",
		"width",
		"height",
		"depth",
		"is_free_shipping",
		"fixed_cost_shipping_price",
		"purchasing_disabled",
		"purchasing_disabled_message",
		"image_url",
		"cost_price",
		"upc",
		"mpn",
		"gtin",
		"inventory_level",
		"inventory_warning_level",
		"bin_picking_number",
		"option_values"
	])
end

#native_top_keyObject



10
11
12
# File 'lib/e_plat/mapping/bigcommerce/v_3/product/variant.rb', line 10

def native_top_key
	"data"
end