e_plat 0.2.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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +339 -0
- data/Rakefile +8 -0
- data/app/assets/config/e_plat_manifest.js +0 -0
- data/config/routes.rb +2 -0
- data/lib/active_resource/schema.rb +59 -0
- data/lib/e_plat/client/default_request_args.rb +33 -0
- data/lib/e_plat/client/platform_convenience_methods.rb +21 -0
- data/lib/e_plat/client.rb +95 -0
- data/lib/e_plat/engine.rb +4 -0
- data/lib/e_plat/errors/incorrect_type_error.rb +8 -0
- data/lib/e_plat/errors/missing_migration_key_error.rb +9 -0
- data/lib/e_plat/errors/missing_session_error.rb +8 -0
- data/lib/e_plat/mapping/base.rb +49 -0
- data/lib/e_plat/mapping/bigcommerce/v_3/product/image.rb +55 -0
- data/lib/e_plat/mapping/bigcommerce/v_3/product/variant.rb +96 -0
- data/lib/e_plat/mapping/bigcommerce/v_3/product.rb +129 -0
- data/lib/e_plat/mapping/bigcommerce/v_3/shop.rb +103 -0
- data/lib/e_plat/mapping/shopify/v_2022_07/product/image.rb +32 -0
- data/lib/e_plat/mapping/shopify/v_2022_07/product/variant.rb +30 -0
- data/lib/e_plat/mapping/shopify/v_2022_07/product.rb +26 -0
- data/lib/e_plat/mapping/shopify/v_2022_07/shop.rb +26 -0
- data/lib/e_plat/mapping.rb +19 -0
- data/lib/e_plat/resource/attribute_interface.rb +60 -0
- data/lib/e_plat/resource/base.rb +145 -0
- data/lib/e_plat/resource/concerns/aliases.rb +100 -0
- data/lib/e_plat/resource/concerns/overwrite_instance_methods.rb +11 -0
- data/lib/e_plat/resource/concerns/overwrite_request_methods.rb +50 -0
- data/lib/e_plat/resource/order/customer.rb +37 -0
- data/lib/e_plat/resource/order/fulfillment.rb +27 -0
- data/lib/e_plat/resource/order/line_item.rb +37 -0
- data/lib/e_plat/resource/order/shipping_line.rb +24 -0
- data/lib/e_plat/resource/order.rb +103 -0
- data/lib/e_plat/resource/product/image.rb +25 -0
- data/lib/e_plat/resource/product/option.rb +16 -0
- data/lib/e_plat/resource/product/variant.rb +51 -0
- data/lib/e_plat/resource/product.rb +35 -0
- data/lib/e_plat/resource/shop.rb +79 -0
- data/lib/e_plat/session.rb +20 -0
- data/lib/e_plat/session_state.rb +25 -0
- data/lib/e_plat/type_coercer.rb +59 -0
- data/lib/e_plat/types.rb +15 -0
- data/lib/e_plat/version.rb +3 -0
- data/lib/e_plat.rb +29 -0
- data/lib/tasks/e_plat_tasks.rake +4 -0
- metadata +256 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module EPlat
|
4
|
+
class Mapping
|
5
|
+
module Bigcommerce
|
6
|
+
module V3
|
7
|
+
class Product
|
8
|
+
class Image < EPlat::Mapping::Base
|
9
|
+
|
10
|
+
def native_top_key
|
11
|
+
"data"
|
12
|
+
end
|
13
|
+
|
14
|
+
def native_attributes
|
15
|
+
super.concat([
|
16
|
+
"id",
|
17
|
+
"product_id",
|
18
|
+
"is_thumbnail",
|
19
|
+
"sort_order",
|
20
|
+
"description",
|
21
|
+
"image_file",
|
22
|
+
"url_zoom",
|
23
|
+
"url_standard",
|
24
|
+
"url_thumbnail",
|
25
|
+
"url_tiny",
|
26
|
+
"date_modified"
|
27
|
+
])
|
28
|
+
end
|
29
|
+
|
30
|
+
def native_attribute_aliases
|
31
|
+
super.concat([
|
32
|
+
{
|
33
|
+
existing_entry: {native_key: "id", e_plat_key: "id"},
|
34
|
+
},
|
35
|
+
{
|
36
|
+
existing_entry: {native_key: "product_id", e_plat_key: "product_id"},
|
37
|
+
},
|
38
|
+
{
|
39
|
+
existing_entry: {native_key: "url_standard", e_plat_key: "src"},
|
40
|
+
},
|
41
|
+
{
|
42
|
+
alias_attribute: {native_key: "date_created", e_plat_key: "created_at"},
|
43
|
+
},
|
44
|
+
{
|
45
|
+
alias_attribute: {native_key: "date_modified", e_plat_key: "updated_at"},
|
46
|
+
},
|
47
|
+
])
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module EPlat
|
4
|
+
class Mapping
|
5
|
+
module Bigcommerce
|
6
|
+
module V3
|
7
|
+
class Product
|
8
|
+
class Variant < EPlat::Mapping::Base
|
9
|
+
|
10
|
+
def native_top_key
|
11
|
+
"data"
|
12
|
+
end
|
13
|
+
|
14
|
+
def native_attributes
|
15
|
+
super.concat([
|
16
|
+
"id",
|
17
|
+
"product_id",
|
18
|
+
"sku",
|
19
|
+
"sku_id",
|
20
|
+
"price",
|
21
|
+
"calculated_price",
|
22
|
+
"sale_price",
|
23
|
+
"retail_price",
|
24
|
+
"map_price",
|
25
|
+
"weight",
|
26
|
+
"calculated_weight",
|
27
|
+
"width",
|
28
|
+
"height",
|
29
|
+
"depth",
|
30
|
+
"is_free_shipping",
|
31
|
+
"fixed_cost_shipping_price",
|
32
|
+
"purchasing_disabled",
|
33
|
+
"purchasing_disabled_message",
|
34
|
+
"image_url",
|
35
|
+
"cost_price",
|
36
|
+
"upc",
|
37
|
+
"mpn",
|
38
|
+
"gtin",
|
39
|
+
"inventory_level",
|
40
|
+
"inventory_warning_level",
|
41
|
+
"bin_picking_number",
|
42
|
+
"option_values"
|
43
|
+
])
|
44
|
+
end
|
45
|
+
|
46
|
+
def native_attribute_aliases
|
47
|
+
super.concat([
|
48
|
+
{
|
49
|
+
existing_entry: {native_key: "id", e_plat_key: "id"}
|
50
|
+
},
|
51
|
+
{
|
52
|
+
existing_entry: {native_key: "price", e_plat_key: "price"}
|
53
|
+
},
|
54
|
+
{
|
55
|
+
existing_entry: {native_key: "sku", e_plat_key: "sku"}
|
56
|
+
},
|
57
|
+
{
|
58
|
+
existing_entry: {native_key: "product_id", e_plat_key: "product_id"}
|
59
|
+
},
|
60
|
+
{
|
61
|
+
alias_attribute: {native_key: "option_values", e_plat_key: "option1",
|
62
|
+
custom_e_plat_getter: "-> (option_values) {
|
63
|
+
if option_values;
|
64
|
+
option_values.first.label;
|
65
|
+
end
|
66
|
+
}",
|
67
|
+
custom_native_setter: "-> (option_value) {
|
68
|
+
if option_values;
|
69
|
+
self.option_values.first.label = option_value;
|
70
|
+
self.option_values;
|
71
|
+
end
|
72
|
+
}"
|
73
|
+
}
|
74
|
+
},
|
75
|
+
{
|
76
|
+
alias_attribute: {native_key: "date_created", e_plat_key: "created_at"},
|
77
|
+
},
|
78
|
+
{
|
79
|
+
alias_attribute: {native_key: "date_modified", e_plat_key: "updated_at"},
|
80
|
+
},
|
81
|
+
{
|
82
|
+
existing_entry: {native_key: "weight", e_plat_key: "weight"}
|
83
|
+
},
|
84
|
+
{
|
85
|
+
existing_entry: {native_key: "inventory_level", e_plat_key: "inventory_quantity"}
|
86
|
+
}
|
87
|
+
])
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
@@ -0,0 +1,129 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module EPlat
|
4
|
+
class Mapping
|
5
|
+
module Bigcommerce
|
6
|
+
module V3
|
7
|
+
class Product < EPlat::Mapping::Base
|
8
|
+
|
9
|
+
def native_top_key
|
10
|
+
"data"
|
11
|
+
end
|
12
|
+
|
13
|
+
def native_attributes
|
14
|
+
super.concat([
|
15
|
+
"id",
|
16
|
+
"name",
|
17
|
+
"type",
|
18
|
+
"sku",
|
19
|
+
"description",
|
20
|
+
"weight",
|
21
|
+
"width",
|
22
|
+
"depth",
|
23
|
+
"height",
|
24
|
+
"price",
|
25
|
+
"cost_price",
|
26
|
+
"retail_price",
|
27
|
+
"sale_price",
|
28
|
+
"map_price",
|
29
|
+
"tax_class_id",
|
30
|
+
"product_tax_code",
|
31
|
+
"calculated_price",
|
32
|
+
"categories",
|
33
|
+
"brand_id",
|
34
|
+
"option_set_id",
|
35
|
+
"option_set_display",
|
36
|
+
"inventory_level",
|
37
|
+
"inventory_warning_level",
|
38
|
+
"inventory_tracking",
|
39
|
+
"reviews_rating_sum",
|
40
|
+
"reviews_count",
|
41
|
+
"total_sold",
|
42
|
+
"fixed_cost_shipping_price",
|
43
|
+
"is_free_shipping",
|
44
|
+
"is_visible",
|
45
|
+
"is_featured",
|
46
|
+
"related_products",
|
47
|
+
"warranty",
|
48
|
+
"bin_picking_number",
|
49
|
+
"layout_file",
|
50
|
+
"upc",
|
51
|
+
"mpn",
|
52
|
+
"gtin",
|
53
|
+
"search_keywords",
|
54
|
+
"availability",
|
55
|
+
"availability_description",
|
56
|
+
"gift_wrapping_options_type",
|
57
|
+
"gift_wrapping_options_list",
|
58
|
+
"sort_order",
|
59
|
+
"condition",
|
60
|
+
"is_condition_shown",
|
61
|
+
"order_quantity_minimum",
|
62
|
+
"order_quantity_maximum",
|
63
|
+
"page_title",
|
64
|
+
"meta_keywords",
|
65
|
+
"meta_description",
|
66
|
+
"date_created",
|
67
|
+
"date_modified",
|
68
|
+
"view_count",
|
69
|
+
"preorder_release_date",
|
70
|
+
"preorder_message",
|
71
|
+
"is_preorder_only",
|
72
|
+
"is_price_hidden",
|
73
|
+
"price_hidden_label",
|
74
|
+
"custom_url",
|
75
|
+
"base_variant_id",
|
76
|
+
"open_graph_type",
|
77
|
+
"open_graph_title",
|
78
|
+
"open_graph_description",
|
79
|
+
"open_graph_use_meta_description",
|
80
|
+
"open_graph_use_product_name",
|
81
|
+
"open_graph_use_image"
|
82
|
+
])
|
83
|
+
end
|
84
|
+
|
85
|
+
def native_attribute_aliases
|
86
|
+
super.concat([
|
87
|
+
{
|
88
|
+
alias_attribute: {native_key: "description", e_plat_key: "body_html"}
|
89
|
+
},
|
90
|
+
{
|
91
|
+
alias_attribute: {native_key: "date_created", e_plat_key: "created_at"},
|
92
|
+
},
|
93
|
+
{
|
94
|
+
alias_attribute: {native_key: "name", e_plat_key: "handle",
|
95
|
+
custom_e_plat_getter: "-> (value) { value&.gsub(' ', '-') }",
|
96
|
+
custom_native_setter: "-> (value) { value&.gsub('-', ' ') }"
|
97
|
+
}
|
98
|
+
},
|
99
|
+
{
|
100
|
+
existing_entry: {native_key: "id", e_plat_key: "id"}
|
101
|
+
},
|
102
|
+
{
|
103
|
+
alias_attribute: {native_key: "availability", e_plat_key: "status",
|
104
|
+
custom_e_plat_getter: "-> (value) {
|
105
|
+
{'preorder'=>'active', 'available' => 'active', 'disabled' => 'draft'}[value] || value
|
106
|
+
}",
|
107
|
+
custom_native_setter: "-> (value) {
|
108
|
+
{'available' => 'active', 'disabled' => 'draft'}.invert[value] || value
|
109
|
+
}" #invert will merge new duped keys
|
110
|
+
}
|
111
|
+
},
|
112
|
+
{
|
113
|
+
alias_attribute: {native_key: "type", e_plat_key: "product_type"}
|
114
|
+
},
|
115
|
+
{
|
116
|
+
alias_attribute: {native_key: "name", e_plat_key: "title"}
|
117
|
+
},
|
118
|
+
{
|
119
|
+
alias_attribute: {native_key: "date_modified", e_plat_key: "updated_at"}
|
120
|
+
}
|
121
|
+
|
122
|
+
])
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module EPlat
|
4
|
+
class Mapping
|
5
|
+
module Bigcommerce
|
6
|
+
module V3
|
7
|
+
class Shop < EPlat::Mapping::Base
|
8
|
+
|
9
|
+
# BigCommerce uses Store instead of Shop. + also only available in v2 API currently.
|
10
|
+
# https://api.bigcommerce.com/stores/{store_hash}/v2/store will need to find a way to make compatible
|
11
|
+
|
12
|
+
def native_top_key
|
13
|
+
"data"
|
14
|
+
end
|
15
|
+
|
16
|
+
def native_attributes
|
17
|
+
super.concat([
|
18
|
+
"id",
|
19
|
+
"account_uuid",
|
20
|
+
"domain",
|
21
|
+
"secure_url",
|
22
|
+
"control_panel_base_url",
|
23
|
+
"status",
|
24
|
+
"name",
|
25
|
+
"first_name",
|
26
|
+
"last_name",
|
27
|
+
"address",
|
28
|
+
"country",
|
29
|
+
"country_code",
|
30
|
+
"phone",
|
31
|
+
"admin_email",
|
32
|
+
"order_email",
|
33
|
+
"favicon_url",
|
34
|
+
"timezone",
|
35
|
+
"language",
|
36
|
+
"currency",
|
37
|
+
"currency_symbol",
|
38
|
+
"decimal_separator",
|
39
|
+
"thousands_separator",
|
40
|
+
"decimal_places",
|
41
|
+
"currency_symbol_location",
|
42
|
+
"weight_units",
|
43
|
+
"dimension_units",
|
44
|
+
"dimension_decimal_places",
|
45
|
+
"dimension_decimal_token",
|
46
|
+
"dimension_thousands_token",
|
47
|
+
"plan_name",
|
48
|
+
"plan_level",
|
49
|
+
"plan_is_trial",
|
50
|
+
"industry",
|
51
|
+
"logo",
|
52
|
+
"is_price_entered_with_tax",
|
53
|
+
"store_id",
|
54
|
+
"default_site_id",
|
55
|
+
"default_channel_id",
|
56
|
+
"active_comparison_modules",
|
57
|
+
"features"
|
58
|
+
])
|
59
|
+
end
|
60
|
+
|
61
|
+
def native_attribute_aliases
|
62
|
+
super.concat([
|
63
|
+
{
|
64
|
+
existing_entry: {native_key: "id", e_plat_key: "id"}
|
65
|
+
},
|
66
|
+
{
|
67
|
+
existing_entry: {native_key: "name", e_plat_key: "name"}
|
68
|
+
},
|
69
|
+
{
|
70
|
+
alias_attribute: {native_key: "admin_email", e_plat_key: "email"}
|
71
|
+
},
|
72
|
+
{
|
73
|
+
existing_entry: {native_key: "domain", e_plat_key: "domain"}
|
74
|
+
},
|
75
|
+
{
|
76
|
+
existing_entry: {native_key: "country", e_plat_key: "country"}
|
77
|
+
},
|
78
|
+
{
|
79
|
+
alias_attribute: {native_key: "address", e_plat_key: "address1"}
|
80
|
+
},
|
81
|
+
{
|
82
|
+
existing_entry: {native_key: "country_code", e_plat_key: "country_code"}
|
83
|
+
},
|
84
|
+
{
|
85
|
+
existing_entry: {native_key: "currency_symbol", e_plat_key: "currency"}
|
86
|
+
},
|
87
|
+
{
|
88
|
+
alias_attribute: {native_key: "currency_symbol", e_plat_key: "currency"}
|
89
|
+
},
|
90
|
+
{
|
91
|
+
existing_entry: {native_key: "plan_name", e_plat_key: "plan_name"}
|
92
|
+
},
|
93
|
+
{
|
94
|
+
alias_attribute: {native_key: "weight_units", e_plat_key: "weight_unit"}
|
95
|
+
}
|
96
|
+
])
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module EPlat
|
4
|
+
class Mapping
|
5
|
+
module Shopify
|
6
|
+
module V202207
|
7
|
+
class Product
|
8
|
+
class Image < EPlat::Mapping::Base
|
9
|
+
|
10
|
+
def native_top_key
|
11
|
+
:itself
|
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
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module EPlat
|
4
|
+
class Mapping
|
5
|
+
module Shopify
|
6
|
+
module V202207
|
7
|
+
class Product
|
8
|
+
class Variant < EPlat::Mapping::Base
|
9
|
+
|
10
|
+
def native_top_key
|
11
|
+
:itself
|
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
|
+
end
|
30
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module EPlat
|
2
|
+
class Mapping
|
3
|
+
module Shopify
|
4
|
+
module V202207 #< :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
|
+
])
|
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 V202207 #< :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,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EPlat
|
4
|
+
class Mapping
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def new_instance(specifc_mapping:)
|
9
|
+
if Object.const_defined?(specifc_mapping)
|
10
|
+
mapping = specifc_mapping.constantize.new
|
11
|
+
else
|
12
|
+
mapping = EPlat::Mapping::Base.new
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module EPlat
|
2
|
+
class AttributeInterface
|
3
|
+
attr_accessor :parent, :keys
|
4
|
+
|
5
|
+
def initialize(parent, keys:)
|
6
|
+
@parent, @keys = parent, keys
|
7
|
+
add_convenience_methods
|
8
|
+
end
|
9
|
+
|
10
|
+
def inspect
|
11
|
+
"#<#{self.class} keys=#{keys.inspect}>"
|
12
|
+
end
|
13
|
+
|
14
|
+
def entries
|
15
|
+
keys.map{|k| {k => parent.send(k)} }.inject(&:merge)
|
16
|
+
end
|
17
|
+
|
18
|
+
define_method :[] do |key|
|
19
|
+
parent.attributes[key]
|
20
|
+
end
|
21
|
+
|
22
|
+
define_method :[]= do |key, value|
|
23
|
+
parent.attributes[key] = value
|
24
|
+
end
|
25
|
+
|
26
|
+
def include?(value)
|
27
|
+
entries.include? value
|
28
|
+
end
|
29
|
+
|
30
|
+
def exclude?(value)
|
31
|
+
!include? value
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def add_convenience_methods
|
38
|
+
keys.each do |key|
|
39
|
+
class_eval <<-STRING
|
40
|
+
define_method "#{ key }" do
|
41
|
+
parent.send("#{key}")
|
42
|
+
end
|
43
|
+
STRING
|
44
|
+
|
45
|
+
class_eval <<-STRING
|
46
|
+
define_method("#{key}=") do |val|
|
47
|
+
parent.send("#{key}=", val)
|
48
|
+
end
|
49
|
+
STRING
|
50
|
+
|
51
|
+
class_eval <<-STRING
|
52
|
+
define_method "#{ key }?" do
|
53
|
+
ActiveModel::Type::Boolean.new.cast parent.send("#{key}")
|
54
|
+
end
|
55
|
+
STRING
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|