e_plat 1.0.0.pre.rc.9 → 1.1.0.pre.rc.1

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +467 -413
  3. data/lib/e_plat/client.rb +9 -5
  4. data/lib/e_plat/mapping/base.rb +22 -3
  5. data/lib/e_plat/mapping/bigcommerce/v_3/order.rb +156 -156
  6. data/lib/e_plat/mapping/woocommerce/v_3/metafield.rb +39 -0
  7. data/lib/e_plat/mapping/woocommerce/v_3/order/billing_address.rb +79 -0
  8. data/lib/e_plat/mapping/woocommerce/v_3/order/line_item.rb +85 -0
  9. data/lib/e_plat/mapping/woocommerce/v_3/order/shipping_address.rb +71 -0
  10. data/lib/e_plat/mapping/woocommerce/v_3/order/shipping_line.rb +54 -0
  11. data/lib/e_plat/mapping/woocommerce/v_3/order.rb +189 -0
  12. data/lib/e_plat/mapping/woocommerce/v_3/product/image.rb +43 -0
  13. data/lib/e_plat/mapping/woocommerce/v_3/product/option.rb +45 -0
  14. data/lib/e_plat/mapping/woocommerce/v_3/product/variant/option_value.rb +40 -0
  15. data/lib/e_plat/mapping/woocommerce/v_3/product/variant.rb +188 -0
  16. data/lib/e_plat/mapping/woocommerce/v_3/product.rb +168 -0
  17. data/lib/e_plat/mapping/woocommerce/v_3/script_tag.rb +22 -0
  18. data/lib/e_plat/mapping/woocommerce/v_3/shop.rb +142 -0
  19. data/lib/e_plat/mapping/woocommerce/v_3/webhook.rb +52 -0
  20. data/lib/e_plat/paginated/woocommerce_pagination.rb +45 -0
  21. data/lib/e_plat/resource/attribute_interface.rb +7 -4
  22. data/lib/e_plat/resource/base.rb +12 -3
  23. data/lib/e_plat/resource/collection.rb +19 -2
  24. data/lib/e_plat/resource/concerns/aliases.rb +14 -6
  25. data/lib/e_plat/resource/concerns/metafieldable.rb +31 -10
  26. data/lib/e_plat/resource/concerns/overwrite_instance_methods.rb +1 -1
  27. data/lib/e_plat/resource/concerns/overwrite_request_methods.rb +12 -1
  28. data/lib/e_plat/resource/countable.rb +7 -0
  29. data/lib/e_plat/resource/order.rb +5 -0
  30. data/lib/e_plat/resource/paginated/link_headers.rb +1 -1
  31. data/lib/e_plat/resource/platform_specific/woocommerce/metafield.rb +41 -0
  32. data/lib/e_plat/resource/platform_specific/woocommerce/order/billing_address.rb +8 -0
  33. data/lib/e_plat/resource/platform_specific/woocommerce/order/line_item.rb +2 -0
  34. data/lib/e_plat/resource/platform_specific/woocommerce/order/shipping_address.rb +8 -0
  35. data/lib/e_plat/resource/platform_specific/woocommerce/order/shipping_line.rb +2 -0
  36. data/lib/e_plat/resource/platform_specific/woocommerce/order.rb +8 -0
  37. data/lib/e_plat/resource/platform_specific/woocommerce/product/image.rb +8 -0
  38. data/lib/e_plat/resource/platform_specific/woocommerce/product/option.rb +8 -0
  39. data/lib/e_plat/resource/platform_specific/woocommerce/product/variant/option_value.rb +10 -0
  40. data/lib/e_plat/resource/platform_specific/woocommerce/product/variant.rb +53 -0
  41. data/lib/e_plat/resource/platform_specific/woocommerce/product.rb +75 -0
  42. data/lib/e_plat/resource/platform_specific/woocommerce/script_tag.rb +5 -0
  43. data/lib/e_plat/resource/platform_specific/woocommerce/shop.rb +36 -0
  44. data/lib/e_plat/resource/platform_specific/woocommerce/webhook.rb +8 -0
  45. data/lib/e_plat/resource/product/variant.rb +2 -0
  46. data/lib/e_plat/utils/money.rb +32 -0
  47. data/lib/e_plat/version.rb +1 -1
  48. data/lib/e_plat.rb +9 -3
  49. metadata +32 -2
@@ -0,0 +1,71 @@
1
+ module EPlat
2
+ class Mapping
3
+ module Woocommerce
4
+ module V3
5
+ class Order
6
+ class ShippingAddress < EPlat::Mapping::Base
7
+ def native_top_key
8
+ :itself
9
+ end
10
+
11
+ def native_attributes
12
+ super.concat([
13
+ "first_name",
14
+ "last_name",
15
+ "company",
16
+ "address_1",
17
+ "address_2",
18
+ "city",
19
+ "state",
20
+ "postcode",
21
+ "country"
22
+ ])
23
+ end
24
+
25
+ def native_attribute_aliases
26
+ super.concat([
27
+ {
28
+ alias_attribute: {native_key: "address_1", e_plat_key: "address1"}
29
+ },
30
+ {
31
+ alias_attribute: {native_key: "address_2", e_plat_key: "address2"}
32
+ },
33
+ {
34
+ existing_entry: {native_key: "city", e_plat_key: "city"}
35
+ },
36
+ {
37
+ existing_entry: {native_key: "company", e_plat_key: "company"}
38
+ },
39
+ {
40
+ existing_entry: {native_key: "country", e_plat_key: "country"}
41
+ },
42
+ {
43
+ existing_entry: {native_key: "first_name", e_plat_key: "first_name"}
44
+ },
45
+ {
46
+ existing_entry: {native_key: "last_name", e_plat_key: "last_name"}
47
+ },
48
+ {
49
+ alias_attribute: {native_key: "state", e_plat_key: "province"}
50
+ },
51
+ {
52
+ alias_attribute: {native_key: "state", e_plat_key: "province_code"}
53
+ },
54
+ {
55
+ alias_attribute: {native_key: "postcode", e_plat_key: "zip"}
56
+ },
57
+ {
58
+ alias_attribute: {native_key: "country", e_plat_key: "country_code"}
59
+ },
60
+ {
61
+ custom_e_plat_getter: {native_key: nil, e_plat_key: "name", custom_e_plat_getter: "-> (obj) { [obj['first_name'], obj['last_name']].join(' ').strip }"}
62
+ }
63
+ # WooCommerce doesn't provide fields for latitude, longitude, and phone in shipping address
64
+ ])
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,54 @@
1
+ module EPlat
2
+ class Mapping
3
+ module Woocommerce
4
+ module V3
5
+ class Order
6
+ class ShippingLine < EPlat::Mapping::Base
7
+ def native_top_key
8
+ :itself
9
+ end
10
+
11
+ def native_attributes
12
+ super.concat([
13
+ "id",
14
+ "method_title",
15
+ "method_id",
16
+ "instance_id",
17
+ "total",
18
+ "total_tax",
19
+ "taxes",
20
+ "meta_data"
21
+ ])
22
+ end
23
+
24
+ def native_attribute_aliases
25
+ super.concat([
26
+ {
27
+ existing_entry: {native_key: "id", e_plat_key: "id"}
28
+ },
29
+ {
30
+ alias_attribute: {native_key: "method_id", e_plat_key: "code"}
31
+ },
32
+ {
33
+ alias_attribute: {native_key: "total", e_plat_key: "price"}
34
+ },
35
+ {
36
+ alias_attribute: {native_key: "total", e_plat_key: "discounted_price"}
37
+ },
38
+ {
39
+ existing_entry: {native_key: "method_title", e_plat_key: "title"}
40
+ },
41
+ {
42
+ existing_entry: {native_key: "taxes", e_plat_key: "tax_lines"}
43
+ },
44
+ {
45
+ custom_e_plat_getter: {native_key: nil, e_plat_key: "carrier_identifier", custom_e_plat_getter: "-> (obj) { obj['method_id'] }"}
46
+ }
47
+ ])
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,189 @@
1
+ module EPlat
2
+ class Mapping
3
+ module Woocommerce
4
+ module V3
5
+ class Order < EPlat::Mapping::Base
6
+
7
+ def native_top_key
8
+ :itself
9
+ end
10
+
11
+ def native_attributes
12
+ super.concat([
13
+ "id",
14
+ "parent_id",
15
+ "number",
16
+ "order_key",
17
+ "created_via",
18
+ "version",
19
+ "status",
20
+ "currency",
21
+ "date_created",
22
+ "date_created_gmt",
23
+ "date_modified",
24
+ "date_modified_gmt",
25
+ "discount_total",
26
+ "discount_tax",
27
+ "shipping_total",
28
+ "shipping_tax",
29
+ "cart_tax",
30
+ "total",
31
+ "total_tax",
32
+ "prices_include_tax",
33
+ "customer_id",
34
+ "customer_ip_address",
35
+ "customer_user_agent",
36
+ "customer_note",
37
+ "billing",
38
+ "shipping",
39
+ "payment_method",
40
+ "payment_method_title",
41
+ "transaction_id",
42
+ "date_paid",
43
+ "date_paid_gmt",
44
+ "date_completed",
45
+ "date_completed_gmt",
46
+ "cart_hash",
47
+ "meta_data",
48
+ "line_items",
49
+ "tax_lines",
50
+ "shipping_lines",
51
+ "fee_lines",
52
+ "coupon_lines",
53
+ "refunds",
54
+ ])
55
+ end
56
+
57
+ def native_attribute_aliases
58
+ super.concat([
59
+ {
60
+ alias_attribute: {native_key: "customer_ip_address", e_plat_key: "browser_ip"}
61
+ },
62
+ {
63
+ alias_attribute: {native_key: "cart_hash", e_plat_key: "cart_token"}
64
+ },
65
+ {
66
+ alias_attribute: {native_key: "date_completed", e_plat_key: "closed_at"}
67
+ },
68
+ {
69
+ alias_attribute: {native_key: "date_created", e_plat_key: "created_at"}
70
+ },
71
+ {
72
+ alias_attribute: {native_key: "discount_total", e_plat_key: "current_total_discounts"}
73
+ },
74
+ {
75
+ alias_attribute: {native_key: 'total_tax', e_plat_key: 'current_total_tax'}
76
+ },
77
+ {
78
+ alias_attribute: {native_key: "coupon_lines", e_plat_key: "discount_codes",
79
+ custom_e_plat_getter: "-> (coupon_lines) { coupon_lines.map(&:code) }",
80
+ custom_native_setter: "-> (discount_codes) { discount_codes.map { |code| { code: code } } }"
81
+ }
82
+ },
83
+ {
84
+ alias_attribute: {native_key: "billing[email]", e_plat_key: "email"}
85
+ },
86
+ {
87
+ alias_attribute: {native_key: "status", e_plat_key: "fulfillment_status",
88
+ custom_e_plat_getter: "-> (status) {
89
+ case status
90
+ when 'completed' then 'fulfilled'
91
+ else 'null'
92
+ end
93
+ }",
94
+ custom_native_setter: "-> (fulfillment_status) {
95
+ case fulfillment_status
96
+ when 'fulfilled' then 'completed'
97
+ else 'pending'
98
+ end
99
+ }"
100
+ }
101
+ },
102
+ {
103
+ alias_attribute: {native_key: "status", e_plat_key: "financial_status",
104
+ custom_e_plat_getter: "-> (status) {
105
+ case status
106
+ when 'processing' then 'paid'
107
+ when 'refunded' then 'refunded'
108
+ when 'failed' then 'voided'
109
+ when 'processing' then 'authorized'
110
+ when 'on-hold' then 'partially_paid'
111
+ else 'pending'
112
+ end
113
+ }",
114
+ custom_native_setter: "-> (financial_status) {
115
+ case financial_status
116
+ when 'paid' then 'processing'
117
+ when 'refunded' then 'refunded'
118
+ when 'voided' then 'failed'
119
+ when 'authorized' then 'processing'
120
+ when 'partially_paid' then 'on-hold'
121
+ else 'pending'
122
+ end
123
+ }"
124
+ }
125
+ },
126
+ {
127
+ alias_attribute: {native_key: "number", e_plat_key: "name"}
128
+ },
129
+ {
130
+ alias_attribute: {native_key: "customer_note", e_plat_key: "note"}
131
+ },
132
+ {
133
+ existing_entry: {native_key: "number", e_plat_key: "number"}
134
+ },
135
+ {
136
+ alias_attribute: {native_key: "number", e_plat_key: "order_number"}
137
+ },
138
+ {
139
+ alias_attribute: {native_key: "billing[phone]", e_plat_key: "phone"}
140
+ },
141
+ {
142
+ alias_attribute: {native_key: "currency", e_plat_key: "presentment_currency"}
143
+ },
144
+ {
145
+ alias_attribute: {native_key: "date_paid", e_plat_key: "processed_at"}
146
+ },
147
+ {
148
+ alias_attribute: {native_key: "payment_method", e_plat_key: "processing_method"}
149
+ },
150
+ {
151
+ alias_attribute: {native_key: "order_key", e_plat_key: "reference"}
152
+ },
153
+ {
154
+ alias_attribute: {native_key: "created_via", e_plat_key: "source_name"}
155
+ },
156
+ {
157
+ existing_entry: {native_key: "tax_lines", e_plat_key: "tax_lines"}
158
+ },
159
+ {
160
+ alias_attribute: {native_key: "discount_total", e_plat_key: "total_discounts"}
161
+ },
162
+ {
163
+ alias_attribute: {native_key: "total", e_plat_key: "total_price"}
164
+ },
165
+ {
166
+ existing_entry: {native_key: "total_tax", e_plat_key: "total_tax"}
167
+ },
168
+ {
169
+ alias_attribute: {native_key: "date_modified", e_plat_key: "updated_at"}
170
+ },
171
+ {
172
+ alias_attribute: {native_key: "billing", e_plat_key: "billing_address"}
173
+ },
174
+ {
175
+ existing_entry: {native_key: "line_items", e_plat_key: "line_items"}
176
+ },
177
+ {
178
+ alias_attribute: {native_key: "shipping", e_plat_key: "shipping_address"}
179
+ },
180
+ {
181
+ existing_entry: {native_key: "shipping_lines", e_plat_key: "shipping_lines"}
182
+ }
183
+ ])
184
+ end
185
+ end
186
+ end
187
+ end
188
+ end
189
+ end
@@ -0,0 +1,43 @@
1
+ module EPlat
2
+ class Mapping
3
+ module Woocommerce
4
+ module V3
5
+ class Product
6
+ class Image < EPlat::Mapping::Base
7
+
8
+ def native_top_key
9
+ :itself
10
+ end
11
+
12
+ def native_attributes
13
+ super.concat([
14
+ "id",
15
+ "date_created",
16
+ "date_created_gmt",
17
+ "date_modified",
18
+ "date_modified_gmt",
19
+ "src",
20
+ "name",
21
+ "alt"
22
+ ])
23
+ end
24
+
25
+ def native_attribute_aliases
26
+ super.concat([
27
+ {
28
+ existing_entry: {native_key: "id", e_plat_key: "id"}
29
+ },
30
+ {
31
+ existing_entry: {native_key: "src", e_plat_key: "src"}
32
+ },
33
+ {
34
+ existing_entry: {native_key: "alt", e_plat_key: "alt"}
35
+ }
36
+ ])
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,45 @@
1
+ module EPlat
2
+ class Mapping
3
+ module Woocommerce
4
+ module V3
5
+ class Product
6
+ class Option < EPlat::Mapping::Base
7
+
8
+ def native_top_key
9
+ :itself
10
+ end
11
+
12
+ def native_attributes
13
+ super.concat([
14
+ "id",
15
+ "name",
16
+ "slug",
17
+ "position",
18
+ "visible",
19
+ "variation",
20
+ "options"
21
+ ])
22
+ end
23
+
24
+ def native_attribute_aliases
25
+ super.concat([
26
+ {
27
+ existing_entry: {native_key: "id", e_plat_key: "id"}
28
+ },
29
+ {
30
+ existing_entry: {native_key: "name", e_plat_key: "name"}
31
+ },
32
+ {
33
+ existing_entry: {native_key: "position", e_plat_key: "position"}
34
+ },
35
+ {
36
+ alias_attribute: {native_key: "options", e_plat_key: "values"}
37
+ }
38
+ ])
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,40 @@
1
+ module EPlat
2
+ class Mapping
3
+ module Woocommerce
4
+ module V3
5
+ class Product
6
+ class Variant
7
+ class OptionValue < EPlat::Mapping::Base
8
+
9
+ def native_top_key
10
+ :itself
11
+ end
12
+
13
+ def native_attributes
14
+ super.concat([
15
+ "id",
16
+ "name",
17
+ "option"
18
+ ])
19
+ end
20
+
21
+ def native_attribute_aliases
22
+ super.concat([
23
+ {
24
+ existing_entry: {native_key: "id", e_plat_key: "id"}
25
+ },
26
+ {
27
+ existing_entry: {native_key: "name", e_plat_key: "name"}
28
+ },
29
+ {
30
+ alias_attribute: {native_key: "option", e_plat_key: "value"}
31
+ }
32
+ ])
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,188 @@
1
+ module EPlat
2
+ class Mapping
3
+ module Woocommerce
4
+ module V3
5
+ class Product
6
+ class Variant < EPlat::Mapping::Base
7
+
8
+ def native_top_key
9
+ :itself
10
+ end
11
+
12
+ def native_attributes
13
+ super.concat([
14
+ "id",
15
+ "date_created",
16
+ "date_created_gmt",
17
+ "date_modified",
18
+ "date_modified_gmt",
19
+ "description",
20
+ "permalink",
21
+ "sku",
22
+ "price",
23
+ "regular_price",
24
+ "sale_price",
25
+ "date_on_sale_from",
26
+ "date_on_sale_from_gmt",
27
+ "date_on_sale_to",
28
+ "date_on_sale_to_gmt",
29
+ "on_sale",
30
+ "status",
31
+ "purchasable",
32
+ "virtual",
33
+ "downloadable",
34
+ "downloads",
35
+ "download_limit",
36
+ "download_expiry",
37
+ "tax_status",
38
+ "tax_class",
39
+ "manage_stock",
40
+ "stock_quantity",
41
+ "stock_status",
42
+ "backorders",
43
+ "backorders_allowed",
44
+ "backordered",
45
+ "weight",
46
+ "dimensions",
47
+ "shipping_class",
48
+ "shipping_class_id",
49
+ "image",
50
+ "attributes",
51
+ "menu_order",
52
+ "meta_data"
53
+ ])
54
+ end
55
+
56
+ def native_attribute_aliases
57
+ super.concat([
58
+ {
59
+ existing_entry: {native_key: "id", e_plat_key: "id"}
60
+ },
61
+ {
62
+ existing_entry: {native_key: "price", e_plat_key: "price"}
63
+ },
64
+ {
65
+ existing_entry: {native_key: "sku", e_plat_key: "sku"}
66
+ },
67
+ {
68
+ existing_entry: {native_key: "title", e_plat_key: "title",
69
+ custom_e_plat_getter: "-> (value) {
70
+ _is_virtual ? product.name : option_values.map(&:option).join(', ')
71
+ }",
72
+ custom_native_setter: "-> (value) {
73
+ nil # variants dont have a name in Woo, it's a result of option values
74
+ }"
75
+ }
76
+ },
77
+ {
78
+ alias_attribute: {
79
+ native_key: "menu_order",
80
+ e_plat_key: "position"
81
+ }
82
+ },
83
+ {
84
+ alias_attribute: {native_key: "description", e_plat_key: "body_html"}
85
+ },
86
+ {
87
+ alias_attribute: {
88
+ native_key: "regular_price",
89
+ e_plat_key: "compare_at_price"
90
+ }
91
+ },
92
+ {
93
+ alias_attribute: {
94
+ native_key: "sale_price",
95
+ e_plat_key: "price"
96
+ }
97
+ },
98
+ {
99
+ alias_attribute: {
100
+ native_key: "date_created",
101
+ e_plat_key: "created_at"
102
+ }
103
+ },
104
+ {
105
+ alias_attribute: {
106
+ native_key: "date_modified",
107
+ e_plat_key: "updated_at"
108
+ }
109
+ },
110
+ {
111
+ alias_attribute: {
112
+ native_key: "tax_status",
113
+ e_plat_key: "taxable",
114
+ custom_e_plat_getter: "-> (value) {
115
+ value == 'taxable'
116
+ }",
117
+ custom_native_setter: "-> (value) {
118
+ value ? 'taxable' : 'none'
119
+ }"
120
+ }
121
+ },
122
+ {
123
+ existing_entry: {
124
+ native_key: "weight",
125
+ e_plat_key: "weight"
126
+ }
127
+ },
128
+ {
129
+ alias_attribute: {
130
+ native_key: "stock_quantity",
131
+ e_plat_key: "inventory_quantity"
132
+ }
133
+ },
134
+ {
135
+ alias_attribute: {
136
+ native_key: "backorders",
137
+ e_plat_key: "inventory_policy",
138
+ custom_e_plat_getter: "-> (value) {
139
+ if manage_stock
140
+ value == 'yes' ? 'continue' : 'deny'
141
+ else
142
+ product.backorders == 'yes' ? 'continue' : 'deny'
143
+ end
144
+ }",
145
+ custom_native_setter: "-> (value) {
146
+ if manage_stock
147
+ (value == 'continue') ? 'yes' : 'no'
148
+ else
149
+ product.backorders = (value == 'continue') ? 'yes' : 'no'
150
+ end
151
+ }"
152
+ }
153
+ },
154
+ {
155
+ alias_attribute: {
156
+ native_key: "tax_class",
157
+ e_plat_key: "tax_code"
158
+ }
159
+ },
160
+ {
161
+ alias_attribute: {
162
+ native_key: "virtual",
163
+ e_plat_key: "requires_shipping",
164
+ custom_e_plat_getter: "-> (value) {
165
+ !value
166
+ }",
167
+ custom_native_setter: "-> (value) {
168
+ !value
169
+ }"
170
+ }
171
+ },
172
+ {
173
+ existing_entry: {native_key: "option_values", e_plat_key: "option_values"}
174
+ }
175
+ ])
176
+ end
177
+
178
+ def protected_attributes_rename_on_initialize
179
+ {
180
+ "attributes" => "option_values"
181
+ }
182
+ end
183
+ end
184
+ end
185
+ end
186
+ end
187
+ end
188
+ end