e_plat 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +84 -54
- data/lib/e_plat/client/default_request_args.rb +1 -1
- data/lib/e_plat/client.rb +34 -8
- data/lib/e_plat/mapping/bigcommerce/v_3/product/option.rb +58 -0
- data/lib/e_plat/mapping/bigcommerce/v_3/product/variant/option_value.rb +42 -0
- data/lib/e_plat/mapping/shopify/v_2024_07/metafield.rb +26 -0
- data/lib/e_plat/mapping/shopify/v_2024_07/order/billing_address.rb +14 -0
- data/lib/e_plat/mapping/shopify/v_2024_07/order/shipping_address.rb +30 -0
- data/lib/e_plat/mapping/shopify/v_2024_07/order.rb +26 -0
- data/lib/e_plat/mapping/shopify/v_2024_07/product/image.rb +52 -0
- data/lib/e_plat/mapping/shopify/v_2024_07/product/option.rb +45 -0
- data/lib/e_plat/mapping/shopify/v_2024_07/product/variant/option_value.rb +58 -0
- data/lib/e_plat/mapping/shopify/v_2024_07/product/variant.rb +180 -0
- data/lib/e_plat/mapping/shopify/v_2024_07/product.rb +100 -0
- data/lib/e_plat/mapping/shopify/v_2024_07/script_tag.rb +26 -0
- data/lib/e_plat/mapping/shopify/v_2024_07/shop.rb +26 -0
- data/lib/e_plat/mapping/shopify/v_2024_07/webhook.rb +29 -0
- data/lib/e_plat/mapping/virtual_collection/shopify/product/variant/option_value.rb +272 -0
- data/lib/e_plat/resource/base.rb +24 -2
- data/lib/e_plat/resource/collection.rb +45 -16
- data/lib/e_plat/resource/concerns/aliases.rb +39 -19
- data/lib/e_plat/resource/concerns/dirty.rb +12 -8
- data/lib/e_plat/resource/concerns/graph_q_lable.rb +253 -0
- data/lib/e_plat/resource/concerns/overwrite_instance_methods.rb +4 -4
- data/lib/e_plat/resource/concerns/overwrite_request_methods.rb +1 -1
- data/lib/e_plat/resource/countable.rb +37 -10
- data/lib/e_plat/resource/platform_specific/bigcommerce/product/variant/option_value.rb +2 -0
- data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/input/product/variant.rb +47 -0
- data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/input/product/variants_bulk.rb +47 -0
- data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/input/product.rb +23 -0
- data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/input.rb +98 -0
- data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/mutation/product/variant.rb +78 -0
- data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/mutation/product.rb +55 -0
- data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/mutation.rb +5 -0
- data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/query/product/variant.rb +44 -0
- data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/query/product.rb +58 -0
- data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/query.rb +5 -0
- data/lib/e_plat/resource/platform_specific/shopify/product/image.rb +13 -1
- data/lib/e_plat/resource/platform_specific/shopify/product/option.rb +13 -1
- data/lib/e_plat/resource/platform_specific/shopify/product/variant/option_value.rb +14 -0
- data/lib/e_plat/resource/platform_specific/shopify/product/variant.rb +65 -1
- data/lib/e_plat/resource/platform_specific/shopify/product.rb +77 -2
- data/lib/e_plat/resource/product/image.rb +8 -5
- data/lib/e_plat/resource/product/option.rb +2 -3
- data/lib/e_plat/resource/product/variant/option_value.rb +17 -0
- data/lib/e_plat/resource/product/variant.rb +4 -10
- data/lib/e_plat/resource/product.rb +23 -11
- data/lib/e_plat/session.rb +3 -2
- data/lib/e_plat/type_coercer.rb +3 -1
- data/lib/e_plat/version.rb +1 -1
- data/lib/e_plat.rb +12 -3
- data/lib/hash.rb +39 -0
- metadata +130 -27
@@ -0,0 +1,180 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module EPlat
|
4
|
+
class Mapping
|
5
|
+
module Shopify
|
6
|
+
module V202407
|
7
|
+
class Product
|
8
|
+
class Variant < EPlat::Mapping::Base
|
9
|
+
include_root_in_request_body true
|
10
|
+
virtual_collection :option_values, class: EPlat::Mapping::VirtualCollection::Shopify::Product::Variant::OptionValue, map_from: "selected_options"
|
11
|
+
|
12
|
+
def native_top_key
|
13
|
+
:itself
|
14
|
+
end
|
15
|
+
|
16
|
+
def native_attributes
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def native_attribute_aliases
|
21
|
+
super.concat([
|
22
|
+
{
|
23
|
+
existing_entry: {native_key: "id", e_plat_key: "id",
|
24
|
+
custom_e_plat_getter: '-> { (_1.is_a? Integer) ? _1 : _1&.split("/")&.last }',
|
25
|
+
custom_native_setter: '-> { (_1.is_a? String) ? _1 : "gid://shopify/ProductVariant/#{_1}" }'
|
26
|
+
}
|
27
|
+
},
|
28
|
+
{
|
29
|
+
existing_entry: {native_key: "title", e_plat_key: "title"}
|
30
|
+
},
|
31
|
+
{
|
32
|
+
existing_entry: {native_key: "price", e_plat_key: "price"}
|
33
|
+
},
|
34
|
+
{
|
35
|
+
existing_entry: {native_key: "sku", e_plat_key: "sku",
|
36
|
+
custom_e_plat_getter: '-> { _1 }',
|
37
|
+
custom_native_setter: '-> do
|
38
|
+
inventory_item.sku = _1;
|
39
|
+
inventory_item.attribute_will_change!("sku");
|
40
|
+
_1
|
41
|
+
end'
|
42
|
+
}
|
43
|
+
},
|
44
|
+
{
|
45
|
+
existing_entry: {native_key: "position", e_plat_key: "position"}
|
46
|
+
},
|
47
|
+
{
|
48
|
+
existing_entry: {native_key: "inventory_policy", e_plat_key: "inventory_policy",
|
49
|
+
custom_e_plat_getter: '-> { _1&.downcase }',
|
50
|
+
custom_native_setter: '-> { _1&.upcase }'
|
51
|
+
}
|
52
|
+
},
|
53
|
+
{
|
54
|
+
existing_entry: {native_key: "compare_at_price", e_plat_key: "compare_at_price"}
|
55
|
+
},
|
56
|
+
{
|
57
|
+
alias_attribute: {native_key: "inventory_item[tracked]", e_plat_key: "inventory_management"}
|
58
|
+
},
|
59
|
+
{
|
60
|
+
|
61
|
+
existing_entry: {native_key: "created_at", e_plat_key: "created_at"}
|
62
|
+
},
|
63
|
+
{
|
64
|
+
existing_entry: {native_key: "updated_at", e_plat_key: "updated_at"}
|
65
|
+
},
|
66
|
+
{
|
67
|
+
existing_entry: {native_key: "taxable", e_plat_key: "taxable"}
|
68
|
+
},
|
69
|
+
{
|
70
|
+
existing_entry: {native_key: "barcode", e_plat_key: "barcode"}
|
71
|
+
},
|
72
|
+
{
|
73
|
+
alias_attribute: {native_key: "inventory_item[measurement][weight][unit]", e_plat_key: "weight_unit",
|
74
|
+
custom_native_setter: '-> { warn("Setting weight_unit directly is not supported on ProductVariant via GraphQL."); _1 }'
|
75
|
+
}
|
76
|
+
},
|
77
|
+
{
|
78
|
+
alias_attribute: {native_key: "inventory_item[measurement][weight][value]", e_plat_key: "weight",
|
79
|
+
custom_native_setter: '-> { warn("Setting weight directly is not supported on ProductVariant via GraphQL."); _1 }'
|
80
|
+
}
|
81
|
+
},
|
82
|
+
{
|
83
|
+
alias_attribute: {native_key: "inventory_item[id]", e_plat_key: "inventory_item_id",
|
84
|
+
custom_e_plat_getter: '-> { _1&.split("/")&.last }',
|
85
|
+
custom_native_setter: '-> { "gid://shopify/InventoryItem/#{_1}" }'
|
86
|
+
}
|
87
|
+
},
|
88
|
+
{
|
89
|
+
existing_entry: {native_key: "inventory_quantity", e_plat_key: "inventory_quantity",
|
90
|
+
custom_native_setter: '-> { warn("Setting inventory_quantity directly is not supported on ProductVariant via GraphQL."); _1 }'
|
91
|
+
}
|
92
|
+
},
|
93
|
+
{
|
94
|
+
existing_entry: {native_key: "tax_code", e_plat_key: "tax_code"}
|
95
|
+
},
|
96
|
+
{
|
97
|
+
alias_attribute: {native_key: "inventory_item[requires_shipping]", e_plat_key: "requires_shipping",
|
98
|
+
custom_native_setter: '-> { warn("Setting requires_shipping directly is not supported on ProductVariant via GraphQL."); _1 }'
|
99
|
+
}
|
100
|
+
},
|
101
|
+
{
|
102
|
+
existing_entry: {native_key: "fulfillment_service", e_plat_key: "fulfillment_service"}
|
103
|
+
},
|
104
|
+
{
|
105
|
+
existing_entry: {native_key: "grams", e_plat_key: "grams", # doesnt exist on any current API but we create it
|
106
|
+
custom_e_plat_getter: '-> {
|
107
|
+
_1
|
108
|
+
case weight_unit
|
109
|
+
when "GRAMS", "grams", "g"
|
110
|
+
weight
|
111
|
+
when "KILOGRAMS", "kilograms", "kg"
|
112
|
+
weight * 1000
|
113
|
+
when "OUNCES", "ounces", "oz"
|
114
|
+
weight * 28.3495
|
115
|
+
when "POUNDS", "pounds", "lb"
|
116
|
+
weight * 453.592
|
117
|
+
else
|
118
|
+
weight
|
119
|
+
end
|
120
|
+
}',
|
121
|
+
custom_native_setter: '-> {
|
122
|
+
warn("Setting grams directly is not supported on ProductVariant via GraphQL. Mutate the inventoryItem.measurement.weight object `value` field instead")
|
123
|
+
case weight_unit
|
124
|
+
when "GRAMS", "grams", "g"
|
125
|
+
_1
|
126
|
+
when "KILOGRAMS", "kilograms", "kg"
|
127
|
+
_1 / 1000
|
128
|
+
when "OUNCES", "ounces", "oz"
|
129
|
+
_1 / 28.3495
|
130
|
+
when "POUNDS", "pounds", "lb"
|
131
|
+
_1 / 453.592
|
132
|
+
else
|
133
|
+
_1
|
134
|
+
end
|
135
|
+
}'
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
])
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# RESOURCE
|
150
|
+
# integer :id
|
151
|
+
# integer :product_id
|
152
|
+
# string :title
|
153
|
+
# string :price
|
154
|
+
# string :sku
|
155
|
+
# integer :position
|
156
|
+
# string :inventory_policy
|
157
|
+
# string :compare_at_price
|
158
|
+
# string :fulfillment_service
|
159
|
+
# string :inventory_management
|
160
|
+
# datetime :created_at
|
161
|
+
# datetime :updated_at
|
162
|
+
# boolean :taxable
|
163
|
+
# string :barcode
|
164
|
+
# integer :grams
|
165
|
+
# integer :image_id
|
166
|
+
# float :weight
|
167
|
+
# string :weight_unit
|
168
|
+
# integer :inventory_item_id
|
169
|
+
# integer :inventory_quantity
|
170
|
+
# string :tax_code
|
171
|
+
# boolean :requires_shipping
|
172
|
+
# string :admin_graphql_api_id
|
173
|
+
|
174
|
+
|
175
|
+
# fields without setter support
|
176
|
+
# | grams | integer | getter only: converted node.inventoryItem[measurement][weight][value] | nil | nil |
|
177
|
+
# | weight | float | getter only: node.inventoryItem[measurement][weight][value] | weight |
|
178
|
+
# | weight_unit | string | getter only: node.inventoryItem[measurement][weight][unit] | nil |
|
179
|
+
# | inventory_item_id | integer | getter only: node.inventoryItem[id]| nil | nil |
|
180
|
+
# | inventory_quantity | integer | getter only: node.inventoryQuantity | inventory_level
|
@@ -0,0 +1,100 @@
|
|
1
|
+
module EPlat
|
2
|
+
class Mapping
|
3
|
+
module Shopify
|
4
|
+
module V202407 #< :module
|
5
|
+
class Product < EPlat::Mapping::Base
|
6
|
+
|
7
|
+
def native_top_key
|
8
|
+
"product"
|
9
|
+
end
|
10
|
+
|
11
|
+
def native_attributes
|
12
|
+
super.concat([
|
13
|
+
"id",
|
14
|
+
"descriptionHtml",
|
15
|
+
"createdAt",
|
16
|
+
"updatedAt",
|
17
|
+
"handle",
|
18
|
+
"productType",
|
19
|
+
"publishedAt",
|
20
|
+
"publishedScope",
|
21
|
+
"status",
|
22
|
+
"tags",
|
23
|
+
"templateSuffix",
|
24
|
+
"title",
|
25
|
+
"vendor"
|
26
|
+
])
|
27
|
+
end
|
28
|
+
|
29
|
+
def native_attribute_aliases
|
30
|
+
super.concat([
|
31
|
+
{
|
32
|
+
alias_attribute: {native_key: "description_html", e_plat_key: "body_html"}
|
33
|
+
},
|
34
|
+
{
|
35
|
+
existing_entry: {native_key: "created_at", e_plat_key: "created_at"}
|
36
|
+
},
|
37
|
+
{
|
38
|
+
existing_entry: {native_key: "updated_at", e_plat_key: "updated_at"}
|
39
|
+
},
|
40
|
+
{
|
41
|
+
existing_entry: {native_key: "handle", e_plat_key: "handle"}
|
42
|
+
},
|
43
|
+
{
|
44
|
+
existing_entry: {native_key: "product_type", e_plat_key: "product_type"}
|
45
|
+
},
|
46
|
+
{
|
47
|
+
existing_entry: {native_key: "published_at", e_plat_key: "published_at"}
|
48
|
+
},
|
49
|
+
{
|
50
|
+
existing_entry: {native_key: "status", e_plat_key: "status",
|
51
|
+
custom_e_plat_getter: '-> { _1&.downcase }',
|
52
|
+
custom_native_setter: '-> { _1&.upcase }'
|
53
|
+
}
|
54
|
+
},
|
55
|
+
{
|
56
|
+
existing_entry: {native_key: "tags", e_plat_key: "tags",
|
57
|
+
custom_e_plat_getter: "-> { _1&.join(',') }",
|
58
|
+
custom_native_setter: "-> { _1&.split(',') }"
|
59
|
+
}
|
60
|
+
},
|
61
|
+
{
|
62
|
+
existing_entry: {native_key: "id", e_plat_key: "id",
|
63
|
+
custom_e_plat_getter: '-> { (_1.is_a? Integer) ? _1 : _1&.split("/")&.last }',
|
64
|
+
custom_native_setter: '-> { (_1.is_a? String) ? _1 : "gid://shopify/Product/#{_1}" }'
|
65
|
+
}
|
66
|
+
},
|
67
|
+
{
|
68
|
+
existing_entry: {native_key: "template_suffix", e_plat_key: "template_suffix"}
|
69
|
+
},
|
70
|
+
{
|
71
|
+
existing_entry: {native_key: "title", e_plat_key: "title"}
|
72
|
+
},
|
73
|
+
{
|
74
|
+
existing_entry: {native_key: "vendor", e_plat_key: "vendor"}
|
75
|
+
}
|
76
|
+
])
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
# string :body_html
|
86
|
+
# datetime :created_at
|
87
|
+
# string :handle
|
88
|
+
# integer :id
|
89
|
+
# array :images
|
90
|
+
# array :options
|
91
|
+
# string :product_type
|
92
|
+
# datetime :published_at
|
93
|
+
# string :status
|
94
|
+
# string :tags
|
95
|
+
# string :admin_graphql_api_id
|
96
|
+
# string :template_suffix
|
97
|
+
# string :title
|
98
|
+
# datetime :updated_at
|
99
|
+
# array :variants
|
100
|
+
# string :vendor
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module EPlat
|
2
|
+
class Mapping
|
3
|
+
module Shopify
|
4
|
+
module V202407 #< :module
|
5
|
+
class ScriptTag < EPlat::Mapping::Base
|
6
|
+
|
7
|
+
def native_top_key
|
8
|
+
"script_tag"
|
9
|
+
end
|
10
|
+
|
11
|
+
def native_attributes
|
12
|
+
super.concat([
|
13
|
+
])
|
14
|
+
end
|
15
|
+
|
16
|
+
def native_attribute_aliases
|
17
|
+
super.concat([
|
18
|
+
])
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module EPlat
|
2
|
+
class Mapping
|
3
|
+
module Shopify
|
4
|
+
module V202407 #< :module
|
5
|
+
class Shop < EPlat::Mapping::Base
|
6
|
+
|
7
|
+
def native_top_key
|
8
|
+
"shop"
|
9
|
+
end
|
10
|
+
|
11
|
+
def native_attributes
|
12
|
+
super.concat([
|
13
|
+
])
|
14
|
+
end
|
15
|
+
|
16
|
+
def native_attribute_aliases
|
17
|
+
super.concat([
|
18
|
+
])
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module EPlat
|
2
|
+
class Mapping
|
3
|
+
module Shopify
|
4
|
+
module V202407 #< :module
|
5
|
+
class Webhook < EPlat::Mapping::Base
|
6
|
+
DEFAULT_VALUES = {
|
7
|
+
format: "json"
|
8
|
+
}
|
9
|
+
|
10
|
+
def native_top_key
|
11
|
+
"webhook"
|
12
|
+
end
|
13
|
+
|
14
|
+
def native_attributes
|
15
|
+
super.concat([
|
16
|
+
])
|
17
|
+
end
|
18
|
+
|
19
|
+
def native_attribute_aliases
|
20
|
+
super.concat([
|
21
|
+
])
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,272 @@
|
|
1
|
+
|
2
|
+
module EPlat
|
3
|
+
class Mapping
|
4
|
+
module VirtualCollection
|
5
|
+
module Shopify
|
6
|
+
module Product
|
7
|
+
module Variant
|
8
|
+
class OptionValue < VirtualCollection::Base
|
9
|
+
attr_accessor :resource
|
10
|
+
|
11
|
+
def initialize(resource:, map_from:)
|
12
|
+
@resource = resource
|
13
|
+
super
|
14
|
+
|
15
|
+
return unless @resource.try :selected_options
|
16
|
+
|
17
|
+
@resource.option_values =
|
18
|
+
@resource.selected_options.map.with_index do |data, i|
|
19
|
+
item = EPlat::Product::Variant::OptionValue.new(variant_id: @resource.id)
|
20
|
+
item.mapping.virtual_collection = self
|
21
|
+
item.add_aliases!(native_attribute_aliases(i), EPlat::Product::Variant::OptionValue.schema)
|
22
|
+
|
23
|
+
item
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def native_attribute_aliases(i)
|
28
|
+
[
|
29
|
+
{
|
30
|
+
alias_attribute: {
|
31
|
+
native_key: "[selected_options][#{i}][option_value][id]",
|
32
|
+
e_plat_key: "id",
|
33
|
+
virtual_collection: true,
|
34
|
+
custom_e_plat_getter: '-> { _1&.split("/")&.last }',
|
35
|
+
custom_native_setter: '-> { "gid://shopify/ProductOptionValue/#{_1}" }'
|
36
|
+
}
|
37
|
+
},
|
38
|
+
{
|
39
|
+
alias_attribute: {
|
40
|
+
native_key: "[selected_options][#{i}][name]",
|
41
|
+
e_plat_key: "name",
|
42
|
+
virtual_collection: true
|
43
|
+
}
|
44
|
+
},
|
45
|
+
{
|
46
|
+
alias_attribute: {
|
47
|
+
native_key: "[selected_options][#{i}][value]",
|
48
|
+
e_plat_key: "value",
|
49
|
+
virtual_collection: true
|
50
|
+
}
|
51
|
+
}
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
# consignments are deliveries, we're just going to operate within the context on one delivery per order
|
67
|
+
# this should be reasonable to tie us over for now
|
68
|
+
|
69
|
+
# integer :id
|
70
|
+
# string :admin_graphql_api_id
|
71
|
+
# integer :fulfillable_quantity
|
72
|
+
# string :fulfillment_service
|
73
|
+
# string :fulfillment_status
|
74
|
+
# boolean :gift_card
|
75
|
+
# integer :grams
|
76
|
+
# string :name
|
77
|
+
# string :price
|
78
|
+
# hash :price_set
|
79
|
+
# boolean :product_exists
|
80
|
+
# integer :product_id
|
81
|
+
# array :properties
|
82
|
+
# integer :quantity
|
83
|
+
# boolean :requires_shipping
|
84
|
+
# string :sku
|
85
|
+
# boolean :taxable
|
86
|
+
# string :title
|
87
|
+
# string :total_discount
|
88
|
+
# hash :total_discount_set
|
89
|
+
# integer :variant_id
|
90
|
+
# string :variant_inventory_management
|
91
|
+
# string :variant_title
|
92
|
+
# string :vendor
|
93
|
+
# array :tax_lines
|
94
|
+
# array :duties
|
95
|
+
# array :discount_allocations
|
96
|
+
|
97
|
+
|
98
|
+
# BG = {
|
99
|
+
# "consignments": [
|
100
|
+
# {
|
101
|
+
# "pickups": [],
|
102
|
+
# "shipping": [
|
103
|
+
# {
|
104
|
+
# "id": 3,
|
105
|
+
# "first_name": "Jane",
|
106
|
+
# "last_name": "Doe",
|
107
|
+
# "company": "",
|
108
|
+
# "street_1": "123 Main Street",
|
109
|
+
# "street_2": "",
|
110
|
+
# "city": "Austin",
|
111
|
+
# "zip": "78751",
|
112
|
+
# "country": "United States",
|
113
|
+
# "country_iso2": "US",
|
114
|
+
# "state": "Texas",
|
115
|
+
# "email": "oli@example.com",
|
116
|
+
# "phone": "",
|
117
|
+
# "form_fields": [],
|
118
|
+
# "line_items": [
|
119
|
+
# {
|
120
|
+
# "id": 3,
|
121
|
+
# "order_id": 102,
|
122
|
+
# "product_id": 88,
|
123
|
+
# "variant_id": 81,
|
124
|
+
# "order_pickup_method_id": 0,
|
125
|
+
# "order_address_id": 3,
|
126
|
+
# "name": "Chemex Coffeemaker",
|
127
|
+
# "name_customer": "Chemex Coffeemaker",
|
128
|
+
# "name_merchant": "Chemex Coffeemaker",
|
129
|
+
# "sku": "CC3C-SM",
|
130
|
+
# "upc": "",
|
131
|
+
# "type": "physical",
|
132
|
+
# "base_price": "83.3300",
|
133
|
+
# "price_ex_tax": "83.3300",
|
134
|
+
# "price_inc_tax": "83.3300",
|
135
|
+
# "price_tax": "0.0000",
|
136
|
+
# "base_total": "83.3300",
|
137
|
+
# "total_ex_tax": "83.3300",
|
138
|
+
# "total_inc_tax": "83.3300",
|
139
|
+
# "total_tax": "0.0000",
|
140
|
+
# "weight": "1.0000",
|
141
|
+
# "width": "0.0000",
|
142
|
+
# "height": "0.0000",
|
143
|
+
# "depth": "0.0000",
|
144
|
+
# "quantity": 1,
|
145
|
+
# "base_cost_price": "0.0000",
|
146
|
+
# "cost_price_inc_tax": "0.0000",
|
147
|
+
# "cost_price_ex_tax": "0.0000",
|
148
|
+
# "cost_price_tax": "0.0000",
|
149
|
+
# "is_refunded": false,
|
150
|
+
# "quantity_refunded": 0,
|
151
|
+
# "refund_amount": "0.0000",
|
152
|
+
# "return_id": 0,
|
153
|
+
# "wrapping_id": 0,
|
154
|
+
# "wrapping_name": "",
|
155
|
+
# "base_wrapping_cost": "0.0000",
|
156
|
+
# "wrapping_cost_ex_tax": "0.0000",
|
157
|
+
# "wrapping_cost_inc_tax": "0.0000",
|
158
|
+
# "wrapping_cost_tax": "0.0000",
|
159
|
+
# "wrapping_message": "",
|
160
|
+
# "quantity_shipped": 0,
|
161
|
+
# "event_name": null,
|
162
|
+
# "event_date": null,
|
163
|
+
# "fixed_shipping_cost": "0.0000",
|
164
|
+
# "ebay_item_id": "",
|
165
|
+
# "ebay_transaction_id": "",
|
166
|
+
# "option_set_id": 18,
|
167
|
+
# "parent_order_product_id": null,
|
168
|
+
# "is_bundled_product": false,
|
169
|
+
# "bin_picking_number": "0",
|
170
|
+
# "external_id": "",
|
171
|
+
# "fulfillment_source": "",
|
172
|
+
# "brand": "",
|
173
|
+
# "gift_certificate_id": null,
|
174
|
+
# "applied_discounts": [],
|
175
|
+
# "product_options": [
|
176
|
+
# {
|
177
|
+
# "id": 2,
|
178
|
+
# "option_id": 34,
|
179
|
+
# "order_product_id": 3,
|
180
|
+
# "product_option_id": 114,
|
181
|
+
# "display_name": "Size",
|
182
|
+
# "display_name_customer": "Size",
|
183
|
+
# "display_name_merchant": "Size",
|
184
|
+
# "display_value": "Small",
|
185
|
+
# "display_value_customer": "Small",
|
186
|
+
# "display_value_merchant": "Small",
|
187
|
+
# "value": "101",
|
188
|
+
# "type": "Multiple choice",
|
189
|
+
# "name": "Size1699441692-88",
|
190
|
+
# "display_style": "Dropdown"
|
191
|
+
# }
|
192
|
+
# ],
|
193
|
+
# "configurable_fields": [],
|
194
|
+
# "discounted_total_inc_tax": "83.3300"
|
195
|
+
# }
|
196
|
+
# ]
|
197
|
+
# }
|
198
|
+
# ],
|
199
|
+
# "items_total": 1,
|
200
|
+
# "items_shipped": 0,
|
201
|
+
# "shipping_method": "None",
|
202
|
+
# "base_cost": 0,
|
203
|
+
# "cost_ex_tax": 0,
|
204
|
+
# "cost_inc_tax": 0,
|
205
|
+
# "cost_tax": 0,
|
206
|
+
# "cost_tax_class_id": 0,
|
207
|
+
# "base_handling_cost": 0,
|
208
|
+
# "handling_cost_ex_tax": 0,
|
209
|
+
# "handling_cost_inc_tax": 0,
|
210
|
+
# "handling_cost_tax": 0,
|
211
|
+
# "handling_cost_tax_class_id": 0,
|
212
|
+
# "shipping_zone_id": 0,
|
213
|
+
# "shipping_zone_name": "",
|
214
|
+
# "shipping_quotes": {
|
215
|
+
# "url": "https://api.bigcommerce.com/stores/d0kmq3bory/v2/orders/102/consignments/shipping/3/shipping_quotes",
|
216
|
+
# "resource": "/orders/102/consignments/shipping/3/shipping_quotes"
|
217
|
+
# }
|
218
|
+
# }
|
219
|
+
# ]
|
220
|
+
# }
|
221
|
+
|
222
|
+
# Shopify = {
|
223
|
+
# "line_items": [
|
224
|
+
# {
|
225
|
+
# "id": 13120677806211,
|
226
|
+
# "admin_graphql_api_id": "gid://shopify/LineItem/13120677806211",
|
227
|
+
# "fulfillable_quantity": 1,
|
228
|
+
# "fulfillment_service": "manual",
|
229
|
+
# "fulfillment_status": null,
|
230
|
+
# "gift_card": false,
|
231
|
+
# "grams": 0,
|
232
|
+
# "name": "Winter Luggage - Sienna the longest name variant in the world",
|
233
|
+
# "price": "150.00",
|
234
|
+
# "price_set": {
|
235
|
+
# "shop_money": {
|
236
|
+
# "amount": "150.00",
|
237
|
+
# "currency_code": "GBP"
|
238
|
+
# },
|
239
|
+
# "presentment_money": {
|
240
|
+
# "amount": "150.00",
|
241
|
+
# "currency_code": "GBP"
|
242
|
+
# }
|
243
|
+
# },
|
244
|
+
# "product_exists": true,
|
245
|
+
# "product_id": 6610509627523,
|
246
|
+
# "properties": [],
|
247
|
+
# "quantity": 1,
|
248
|
+
# "requires_shipping": true,
|
249
|
+
# "sku": "skusku123",
|
250
|
+
# "taxable": true,
|
251
|
+
# "title": "Winter Luggage",
|
252
|
+
# "total_discount": "0.00",
|
253
|
+
# "total_discount_set": {
|
254
|
+
# "shop_money": {
|
255
|
+
# "amount": "0.00",
|
256
|
+
# "currency_code": "GBP"
|
257
|
+
# },
|
258
|
+
# "presentment_money": {
|
259
|
+
# "amount": "0.00",
|
260
|
+
# "currency_code": "GBP"
|
261
|
+
# }
|
262
|
+
# },
|
263
|
+
# "variant_id": 39428269408387,
|
264
|
+
# "variant_inventory_management": "shopify",
|
265
|
+
# "variant_title": "Sienna the longest name variant in the world",
|
266
|
+
# "vendor": "PreProduct Test",
|
267
|
+
# "tax_lines": [],
|
268
|
+
# "duties": [],
|
269
|
+
# "discount_allocations": []
|
270
|
+
# }
|
271
|
+
# ]
|
272
|
+
# }
|
data/lib/e_plat/resource/base.rb
CHANGED
@@ -4,6 +4,7 @@ module EPlat
|
|
4
4
|
class Base < ActiveResource::Base
|
5
5
|
include Concerns::OverwriteRequestMethods, Concerns::OverwriteInstanceMethods
|
6
6
|
include Concerns::Aliases, Concerns::Dirty, Concerns::FullJson
|
7
|
+
include Concerns::GraphQLable
|
7
8
|
|
8
9
|
self.connection_class = EPlat::Connection
|
9
10
|
self.collection_parser = EPlat::Collection
|
@@ -92,6 +93,7 @@ module EPlat
|
|
92
93
|
|
93
94
|
@mapped_attributes = ensure_e_plat_attributes!
|
94
95
|
ensure_native_attributes!
|
96
|
+
|
95
97
|
add_aliases!(mapping.native_attribute_aliases, type_schema || {})
|
96
98
|
end
|
97
99
|
|
@@ -105,7 +107,7 @@ module EPlat
|
|
105
107
|
|
106
108
|
def native_keys
|
107
109
|
if client.shopify?
|
108
|
-
schema.keys # EPlat uses Shopify's schema,
|
110
|
+
@mapping.native_attributes.presence || schema.keys # EPlat uses Shopify's schema, apar from a couple of Graphql only fields
|
109
111
|
elsif mapping.class.to_s != EPlat::Mapping::Base && @mapping.native_attributes.present?
|
110
112
|
@mapping.native_attributes.presence
|
111
113
|
else
|
@@ -126,6 +128,26 @@ module EPlat
|
|
126
128
|
|
127
129
|
top_level_resource?
|
128
130
|
end
|
131
|
+
|
132
|
+
def formatted_id(id)
|
133
|
+
return id unless client.shopify? && client.api_version != "2024_01"
|
134
|
+
return if id.to_s.include?("gid://")
|
135
|
+
|
136
|
+
case element_name
|
137
|
+
when "product"
|
138
|
+
"gid://shopify/Product/#{id}"
|
139
|
+
when "variant"
|
140
|
+
"gid://shopify/ProductVariant/#{id}"
|
141
|
+
when "image"
|
142
|
+
"gid://shopify/ProductImage/#{id}"
|
143
|
+
else
|
144
|
+
raise EPlat::Errors.new("Unsupported element name")
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def graphql_input
|
149
|
+
raise EPlat::Error.new("GraphQL input not supported for this resource and platform")
|
150
|
+
end
|
129
151
|
|
130
152
|
private
|
131
153
|
|
@@ -134,7 +156,7 @@ module EPlat
|
|
134
156
|
end
|
135
157
|
|
136
158
|
def ensure_native_attributes!
|
137
|
-
return if client.shopify?
|
159
|
+
return if client.shopify? && EPlat.config.shopify_api_version == "2024_01"
|
138
160
|
|
139
161
|
AttributeInterface.new(self, keys: native_keys)
|
140
162
|
end
|