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.
- checksums.yaml +4 -4
- data/README.md +467 -413
- data/lib/e_plat/client.rb +9 -5
- data/lib/e_plat/mapping/base.rb +22 -3
- data/lib/e_plat/mapping/bigcommerce/v_3/order.rb +156 -156
- data/lib/e_plat/mapping/woocommerce/v_3/metafield.rb +39 -0
- data/lib/e_plat/mapping/woocommerce/v_3/order/billing_address.rb +79 -0
- data/lib/e_plat/mapping/woocommerce/v_3/order/line_item.rb +85 -0
- data/lib/e_plat/mapping/woocommerce/v_3/order/shipping_address.rb +71 -0
- data/lib/e_plat/mapping/woocommerce/v_3/order/shipping_line.rb +54 -0
- data/lib/e_plat/mapping/woocommerce/v_3/order.rb +189 -0
- data/lib/e_plat/mapping/woocommerce/v_3/product/image.rb +43 -0
- data/lib/e_plat/mapping/woocommerce/v_3/product/option.rb +45 -0
- data/lib/e_plat/mapping/woocommerce/v_3/product/variant/option_value.rb +40 -0
- data/lib/e_plat/mapping/woocommerce/v_3/product/variant.rb +188 -0
- data/lib/e_plat/mapping/woocommerce/v_3/product.rb +168 -0
- data/lib/e_plat/mapping/woocommerce/v_3/script_tag.rb +22 -0
- data/lib/e_plat/mapping/woocommerce/v_3/shop.rb +142 -0
- data/lib/e_plat/mapping/woocommerce/v_3/webhook.rb +52 -0
- data/lib/e_plat/paginated/woocommerce_pagination.rb +45 -0
- data/lib/e_plat/resource/attribute_interface.rb +7 -4
- data/lib/e_plat/resource/base.rb +12 -3
- data/lib/e_plat/resource/collection.rb +19 -2
- data/lib/e_plat/resource/concerns/aliases.rb +14 -6
- data/lib/e_plat/resource/concerns/metafieldable.rb +31 -10
- data/lib/e_plat/resource/concerns/overwrite_instance_methods.rb +1 -1
- data/lib/e_plat/resource/concerns/overwrite_request_methods.rb +12 -1
- data/lib/e_plat/resource/countable.rb +7 -0
- data/lib/e_plat/resource/order.rb +5 -0
- data/lib/e_plat/resource/paginated/link_headers.rb +1 -1
- data/lib/e_plat/resource/platform_specific/woocommerce/metafield.rb +41 -0
- data/lib/e_plat/resource/platform_specific/woocommerce/order/billing_address.rb +8 -0
- data/lib/e_plat/resource/platform_specific/woocommerce/order/line_item.rb +2 -0
- data/lib/e_plat/resource/platform_specific/woocommerce/order/shipping_address.rb +8 -0
- data/lib/e_plat/resource/platform_specific/woocommerce/order/shipping_line.rb +2 -0
- data/lib/e_plat/resource/platform_specific/woocommerce/order.rb +8 -0
- data/lib/e_plat/resource/platform_specific/woocommerce/product/image.rb +8 -0
- data/lib/e_plat/resource/platform_specific/woocommerce/product/option.rb +8 -0
- data/lib/e_plat/resource/platform_specific/woocommerce/product/variant/option_value.rb +10 -0
- data/lib/e_plat/resource/platform_specific/woocommerce/product/variant.rb +53 -0
- data/lib/e_plat/resource/platform_specific/woocommerce/product.rb +75 -0
- data/lib/e_plat/resource/platform_specific/woocommerce/script_tag.rb +5 -0
- data/lib/e_plat/resource/platform_specific/woocommerce/shop.rb +36 -0
- data/lib/e_plat/resource/platform_specific/woocommerce/webhook.rb +8 -0
- data/lib/e_plat/resource/product/variant.rb +2 -0
- data/lib/e_plat/utils/money.rb +32 -0
- data/lib/e_plat/version.rb +1 -1
- data/lib/e_plat.rb +9 -3
- metadata +32 -2
data/lib/e_plat/client.rb
CHANGED
@@ -7,7 +7,8 @@ module EPlat
|
|
7
7
|
SHOPIFY_REST_PAGINATION_PARAM = "page_info"
|
8
8
|
SHOPIFY_GRAPHQL_FORWARD_PAGINATION_PARAM = "after"
|
9
9
|
SHOPIFY_GRAPHQL_BACKWARD_PAGINATION_PARAM = "before"
|
10
|
-
BIGCOMMERCE_PAGINATION_PARAM
|
10
|
+
BIGCOMMERCE_PAGINATION_PARAM = "page"
|
11
|
+
WOOCOMMERCE_PAGINATION_PARAM = "page"
|
11
12
|
|
12
13
|
attr_reader :platform, :store_url, :api_token, :api_version, :store_hash
|
13
14
|
|
@@ -53,7 +54,7 @@ module EPlat
|
|
53
54
|
when :bigcommerce
|
54
55
|
"https://api.bigcommerce.com"
|
55
56
|
when :woocommerce
|
56
|
-
"
|
57
|
+
"https://#{ store_url }"
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
@@ -83,7 +84,7 @@ module EPlat
|
|
83
84
|
when :bigcommerce
|
84
85
|
"/stores/#{ store_hash }/v#{ api_version }/catalog/#{ collection_path }"
|
85
86
|
when :woocommerce
|
86
|
-
"/" # not yet supported
|
87
|
+
"/wp-json/wc/v#{ api_version }/#{ collection_path }" # not yet supported
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
@@ -117,7 +118,7 @@ module EPlat
|
|
117
118
|
when :woocommerce
|
118
119
|
{
|
119
120
|
"Content-Type" => "application/json",
|
120
|
-
"Authorization" => "
|
121
|
+
"Authorization" => "Basic #{ api_token }"
|
121
122
|
}
|
122
123
|
end
|
123
124
|
end
|
@@ -143,6 +144,7 @@ module EPlat
|
|
143
144
|
case platform
|
144
145
|
when :shopify then true
|
145
146
|
when :bigcommerce then false
|
147
|
+
when :woocommerce then false # haven't tested this is the case yet
|
146
148
|
else false
|
147
149
|
end
|
148
150
|
end
|
@@ -157,11 +159,13 @@ module EPlat
|
|
157
159
|
end
|
158
160
|
when :bigcommerce
|
159
161
|
BIGCOMMERCE_PAGINATION_PARAM
|
162
|
+
when :woocommerce
|
163
|
+
WOOCOMMERCE_PAGINATION_PARAM
|
160
164
|
end
|
161
165
|
end
|
162
166
|
|
163
167
|
def include_format_in_path?
|
164
|
-
!bigcommerce?
|
168
|
+
!bigcommerce? && !woocommerce?
|
165
169
|
end
|
166
170
|
|
167
171
|
|
data/lib/e_plat/mapping/base.rb
CHANGED
@@ -25,7 +25,6 @@ module EPlat
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
28
|
def initialize(resource_instance)
|
30
29
|
@resource = resource_instance
|
31
30
|
|
@@ -36,7 +35,7 @@ module EPlat
|
|
36
35
|
"#<#{self.class} #{ self.instance_variable_names.join(' ') }>"
|
37
36
|
end
|
38
37
|
|
39
|
-
# The below
|
38
|
+
# The below methods are added to via the individual mapping classes
|
40
39
|
|
41
40
|
def native_top_key
|
42
41
|
:itself # or top key of JSON response e.g. "data", "product",
|
@@ -63,6 +62,10 @@ module EPlat
|
|
63
62
|
]
|
64
63
|
end
|
65
64
|
|
65
|
+
# for resources with keys in EPlat::Base::PROTECTED_ATTRIBUTES
|
66
|
+
# we can swap over before init and restore in as_json. {native_key => e_plat_key}
|
67
|
+
def protected_attributes_rename_on_initialize = {}
|
68
|
+
|
66
69
|
# The below methods add support for getting/setting/converting via e_plat and native keys
|
67
70
|
|
68
71
|
def aliases #e.g. {description: "body_html", native_key: "e_plat_key", ...}
|
@@ -109,7 +112,19 @@ module EPlat
|
|
109
112
|
@mapping ||= native_attribute_aliases.map{|a| a[:alias_attribute] }.compact_blank.inject(&:merge) || {}
|
110
113
|
end
|
111
114
|
|
112
|
-
def
|
115
|
+
def platform
|
116
|
+
class_name = self.class.name.underscore
|
117
|
+
case
|
118
|
+
when class_name.include?("shopify")
|
119
|
+
:shopify
|
120
|
+
when class_name.include?("bigcommerce")
|
121
|
+
:bigcommerce
|
122
|
+
when class_name.include?("woocommerce")
|
123
|
+
:woocommerce
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def via_native_attributes_where_possible(params, search:false) # e.g. {financial_status: 'paid'} => {status_id: 11}
|
113
128
|
e_plat_key_mappings = keys_aliased_to_native_keys.with_indifferent_access # {e_plat_key: native_key}
|
114
129
|
translated_attributes = {}
|
115
130
|
|
@@ -123,6 +138,10 @@ module EPlat
|
|
123
138
|
end
|
124
139
|
end
|
125
140
|
|
141
|
+
if search && platform == :woocommerce
|
142
|
+
translated_attributes.transform_keys!{(_1 == "name" || _1 == "sku") ? "search" : _1}
|
143
|
+
end
|
144
|
+
|
126
145
|
translated_attributes
|
127
146
|
end
|
128
147
|
|
@@ -1,163 +1,163 @@
|
|
1
1
|
module EPlat
|
2
2
|
class Mapping
|
3
3
|
module Bigcommerce
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
module V3 #v2 used, as v3 order not yet available
|
5
|
+
class Order < EPlat::Mapping::Base
|
6
|
+
virtual_collection :line_items, class: EPlat::Mapping::VirtualCollection::Bigcommerce::OrderLineItems, map_from: "consignments"
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
def native_top_key
|
9
|
+
"data"
|
10
|
+
end
|
11
|
+
|
12
|
+
def native_attributes
|
13
|
+
super.concat([
|
14
|
+
"id",
|
15
|
+
"customer_id",
|
16
|
+
"date_created",
|
17
|
+
"date_modified",
|
18
|
+
"date_shipped",
|
19
|
+
"status_id",
|
20
|
+
"status",
|
21
|
+
"subtotal_ex_tax",
|
22
|
+
"subtotal_inc_tax",
|
23
|
+
"subtotal_tax",
|
24
|
+
"base_shipping_cost",
|
25
|
+
"shipping_cost_ex_tax",
|
26
|
+
"shipping_cost_inc_tax",
|
27
|
+
"shipping_cost_tax",
|
28
|
+
"shipping_cost_tax_class_id",
|
29
|
+
"base_handling_cost",
|
30
|
+
"handling_cost_ex_tax",
|
31
|
+
"handling_cost_inc_tax",
|
32
|
+
"handling_cost_tax",
|
33
|
+
"handling_cost_tax_class_id",
|
34
|
+
"base_wrapping_cost",
|
35
|
+
"wrapping_cost_ex_tax",
|
36
|
+
"wrapping_cost_inc_tax",
|
37
|
+
"wrapping_cost_tax",
|
38
|
+
"wrapping_cost_tax_class_id",
|
39
|
+
"total_ex_tax",
|
40
|
+
"total_inc_tax",
|
41
|
+
"total_tax",
|
42
|
+
"items_total",
|
43
|
+
"items_shipped",
|
44
|
+
"payment_method",
|
45
|
+
"payment_provider_id",
|
46
|
+
"payment_status",
|
47
|
+
"refunded_amount",
|
48
|
+
"order_is_digital",
|
49
|
+
"store_credit_amount",
|
50
|
+
"gift_certificate_amount",
|
51
|
+
"ip_address",
|
52
|
+
"ip_address_v6",
|
53
|
+
"geoip_country",
|
54
|
+
"geoip_country_iso2",
|
55
|
+
"currency_id",
|
56
|
+
"currency_code",
|
57
|
+
"currency_exchange_rate",
|
58
|
+
"default_currency_id",
|
59
|
+
"default_currency_code",
|
60
|
+
"staff_notes",
|
61
|
+
"customer_message",
|
62
|
+
"discount_amount",
|
63
|
+
"coupon_discount",
|
64
|
+
"shipping_address_count",
|
65
|
+
"is_deleted",
|
66
|
+
"ebay_order_id",
|
67
|
+
"cart_id",
|
68
|
+
"billing_address",
|
69
|
+
"is_email_opt_in",
|
70
|
+
"credit_card_type",
|
71
|
+
"order_source",
|
72
|
+
"channel_id",
|
73
|
+
"external_source",
|
74
|
+
"products",
|
75
|
+
"shipping_addresses",
|
76
|
+
"coupons",
|
77
|
+
"external_id",
|
78
|
+
"external_merchant_id",
|
79
|
+
"tax_provider_id",
|
80
|
+
"store_default_currency_code",
|
81
|
+
"store_default_to_transactional_exchange_rate",
|
82
|
+
"custom_status",
|
83
|
+
"customer_locale",
|
84
|
+
"external_order_id"
|
85
|
+
])
|
86
|
+
end
|
87
|
+
|
88
|
+
def native_attribute_aliases
|
89
|
+
super.concat([
|
90
|
+
{
|
91
|
+
alias_attribute: {native_key: "date_created", e_plat_key: "created_at"}
|
92
|
+
},
|
93
|
+
{
|
94
|
+
alias_attribute: {native_key: "date_modified", e_plat_key: "updated_at"}
|
95
|
+
},
|
96
|
+
{
|
97
|
+
alias_attribute: {native_key: "status_id", e_plat_key: "financial_status",
|
98
|
+
custom_e_plat_getter: "-> (status_id) {
|
99
|
+
case status_id.to_i
|
100
|
+
when 1 then 'pending'
|
101
|
+
when 4 then 'refunded'
|
102
|
+
when 5 then 'cancelled' # not a valid status for Shopify. just used in this BG specific mapping
|
103
|
+
when 7 then 'unpaid'
|
104
|
+
when 11 then 'paid'
|
105
|
+
else nil
|
106
|
+
end
|
107
|
+
}",
|
108
|
+
custom_native_setter: "-> (financial_status) {
|
109
|
+
case financial_status
|
110
|
+
when 'pending' then 1
|
111
|
+
when 'refunded' then 4
|
112
|
+
when 'cancelled' then 5
|
113
|
+
when 'unpaid' then 7
|
114
|
+
when 'paid' then 11
|
115
|
+
else nil
|
116
|
+
end
|
117
|
+
}"
|
118
|
+
}
|
119
|
+
},
|
120
|
+
{
|
121
|
+
existing_entry: {native_key: "billing_address", e_plat_key: "billing_address"}
|
122
|
+
},
|
123
|
+
{
|
124
|
+
alias_attribute: {native_key: "currency_code", e_plat_key: "currency"}
|
125
|
+
},
|
126
|
+
{
|
127
|
+
alias_attribute: {native_key: 'subtotal_ex_tax', e_plat_key: 'subtotal_price'} #poundage string. eg "5.31"
|
128
|
+
},
|
129
|
+
{
|
130
|
+
existing_entry: {native_key: 'total_tax', e_plat_key: 'total_tax'} #poundage string. eg "5.31"
|
131
|
+
},
|
132
|
+
{
|
133
|
+
alias_attribute: {native_key: 'total_inc_tax', e_plat_key: 'total_price'} #poundage string. eg "5.31"
|
134
|
+
},
|
135
|
+
{
|
136
|
+
existing_entry: {native_key: 'id', e_plat_key: 'id'}
|
137
|
+
},
|
138
|
+
{
|
139
|
+
existing_entry: {native_key: 'customer_locale', e_plat_key: 'customer_locale'} #e.g. "en-{optional_country_code}"
|
140
|
+
},
|
141
|
+
{
|
142
|
+
alias_attribute: {native_key: "total_inc_tax", e_plat_key: "current_total_price"}
|
143
|
+
},
|
144
|
+
{
|
145
|
+
alias_attribute: {native_key: "discount_amount", e_plat_key: "current_total_discounts"} #poundage string. eg "9.99"
|
146
|
+
},
|
147
|
+
{
|
148
|
+
alias_attribute: {native_key: "id", e_plat_key: "order_number"}
|
149
|
+
},
|
150
|
+
{
|
151
|
+
alias_attribute: {native_key: "staff_notes", e_plat_key: "note"}
|
152
|
+
},
|
153
|
+
{
|
154
|
+
alias_attribute: {native_key: "billing_address[email]", e_plat_key: "email"}
|
155
|
+
}
|
156
|
+
])
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
10
160
|
end
|
11
|
-
|
12
|
-
def native_attributes
|
13
|
-
super.concat([
|
14
|
-
"id",
|
15
|
-
"customer_id",
|
16
|
-
"date_created",
|
17
|
-
"date_modified",
|
18
|
-
"date_shipped",
|
19
|
-
"status_id",
|
20
|
-
"status",
|
21
|
-
"subtotal_ex_tax",
|
22
|
-
"subtotal_inc_tax",
|
23
|
-
"subtotal_tax",
|
24
|
-
"base_shipping_cost",
|
25
|
-
"shipping_cost_ex_tax",
|
26
|
-
"shipping_cost_inc_tax",
|
27
|
-
"shipping_cost_tax",
|
28
|
-
"shipping_cost_tax_class_id",
|
29
|
-
"base_handling_cost",
|
30
|
-
"handling_cost_ex_tax",
|
31
|
-
"handling_cost_inc_tax",
|
32
|
-
"handling_cost_tax",
|
33
|
-
"handling_cost_tax_class_id",
|
34
|
-
"base_wrapping_cost",
|
35
|
-
"wrapping_cost_ex_tax",
|
36
|
-
"wrapping_cost_inc_tax",
|
37
|
-
"wrapping_cost_tax",
|
38
|
-
"wrapping_cost_tax_class_id",
|
39
|
-
"total_ex_tax",
|
40
|
-
"total_inc_tax",
|
41
|
-
"total_tax",
|
42
|
-
"items_total",
|
43
|
-
"items_shipped",
|
44
|
-
"payment_method",
|
45
|
-
"payment_provider_id",
|
46
|
-
"payment_status",
|
47
|
-
"refunded_amount",
|
48
|
-
"order_is_digital",
|
49
|
-
"store_credit_amount",
|
50
|
-
"gift_certificate_amount",
|
51
|
-
"ip_address",
|
52
|
-
"ip_address_v6",
|
53
|
-
"geoip_country",
|
54
|
-
"geoip_country_iso2",
|
55
|
-
"currency_id",
|
56
|
-
"currency_code",
|
57
|
-
"currency_exchange_rate",
|
58
|
-
"default_currency_id",
|
59
|
-
"default_currency_code",
|
60
|
-
"staff_notes",
|
61
|
-
"customer_message",
|
62
|
-
"discount_amount",
|
63
|
-
"coupon_discount",
|
64
|
-
"shipping_address_count",
|
65
|
-
"is_deleted",
|
66
|
-
"ebay_order_id",
|
67
|
-
"cart_id",
|
68
|
-
"billing_address",
|
69
|
-
"is_email_opt_in",
|
70
|
-
"credit_card_type",
|
71
|
-
"order_source",
|
72
|
-
"channel_id",
|
73
|
-
"external_source",
|
74
|
-
"products",
|
75
|
-
"shipping_addresses",
|
76
|
-
"coupons",
|
77
|
-
"external_id",
|
78
|
-
"external_merchant_id",
|
79
|
-
"tax_provider_id",
|
80
|
-
"store_default_currency_code",
|
81
|
-
"store_default_to_transactional_exchange_rate",
|
82
|
-
"custom_status",
|
83
|
-
"customer_locale",
|
84
|
-
"external_order_id"
|
85
|
-
])
|
86
|
-
end
|
87
|
-
|
88
|
-
def native_attribute_aliases
|
89
|
-
super.concat([
|
90
|
-
{
|
91
|
-
alias_attribute: {native_key: "date_created", e_plat_key: "created_at"}
|
92
|
-
},
|
93
|
-
{
|
94
|
-
alias_attribute: {native_key: "date_modified", e_plat_key: "updated_at"}
|
95
|
-
},
|
96
|
-
{
|
97
|
-
alias_attribute: {native_key: "status_id", e_plat_key: "financial_status",
|
98
|
-
custom_e_plat_getter: "-> (status_id) {
|
99
|
-
case status_id.to_i
|
100
|
-
when 1 then 'pending'
|
101
|
-
when 4 then 'refunded'
|
102
|
-
when 5 then 'cancelled' # not a valid status for Shopify. just used in this BG specific mapping
|
103
|
-
when 7 then 'unpaid'
|
104
|
-
when 11 then 'paid'
|
105
|
-
else nil
|
106
|
-
end
|
107
|
-
}",
|
108
|
-
custom_native_setter: "-> (financial_status) {
|
109
|
-
case financial_status
|
110
|
-
when 'pending' then 1
|
111
|
-
when 'refunded' then 4
|
112
|
-
when 'cancelled' then 5
|
113
|
-
when 'unpaid' then 7
|
114
|
-
when 'paid' then 11
|
115
|
-
else nil
|
116
|
-
end
|
117
|
-
}"
|
118
|
-
}
|
119
|
-
},
|
120
|
-
{
|
121
|
-
existing_entry: {native_key: "billing_address", e_plat_key: "billing_address"}
|
122
|
-
},
|
123
|
-
{
|
124
|
-
alias_attribute: {native_key: "currency_code", e_plat_key: "currency"}
|
125
|
-
},
|
126
|
-
{
|
127
|
-
alias_attribute: {native_key: 'subtotal_ex_tax', e_plat_key: 'subtotal_price'} #poundage string. eg "5.31"
|
128
|
-
},
|
129
|
-
{
|
130
|
-
existing_entry: {native_key: 'total_tax', e_plat_key: 'total_tax'} #poundage string. eg "5.31"
|
131
|
-
},
|
132
|
-
{
|
133
|
-
alias_attribute: {native_key: 'total_inc_tax', e_plat_key: 'total_price'} #poundage string. eg "5.31"
|
134
|
-
},
|
135
|
-
{
|
136
|
-
existing_entry: {native_key: 'id', e_plat_key: 'id'}
|
137
|
-
},
|
138
|
-
{
|
139
|
-
existing_entry: {native_key: 'customer_locale', e_plat_key: 'customer_locale'} #e.g. "en-{optional_country_code}"
|
140
|
-
},
|
141
|
-
{
|
142
|
-
alias_attribute: {native_key: "total_inc_tax", e_plat_key: "current_total_price"}
|
143
|
-
},
|
144
|
-
{
|
145
|
-
alias_attribute: {native_key: "discount_amount", e_plat_key: "current_total_discounts"} #poundage string. eg "9.99"
|
146
|
-
},
|
147
|
-
{
|
148
|
-
alias_attribute: {native_key: "id", e_plat_key: "order_number"}
|
149
|
-
},
|
150
|
-
{
|
151
|
-
alias_attribute: {native_key: "staff_notes", e_plat_key: "note"}
|
152
|
-
},
|
153
|
-
{
|
154
|
-
alias_attribute: {native_key: "billing_address[email]", e_plat_key: "email"}
|
155
|
-
}
|
156
|
-
])
|
157
|
-
end
|
158
|
-
|
159
|
-
end
|
160
161
|
end
|
161
|
-
end
|
162
162
|
end
|
163
|
-
|
163
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module EPlat
|
2
|
+
class Mapping
|
3
|
+
module Woocommerce
|
4
|
+
module V3
|
5
|
+
class Metafield < EPlat::Mapping::Base
|
6
|
+
# WooCommerce Metafield mapping
|
7
|
+
# In WooCommerce, metafields are part of a resource's returned meta_data array
|
8
|
+
# Each metafield has id, key, and value attributes
|
9
|
+
|
10
|
+
def native_top_key
|
11
|
+
:itself
|
12
|
+
end
|
13
|
+
|
14
|
+
def native_attributes
|
15
|
+
super.concat([
|
16
|
+
"id",
|
17
|
+
"key",
|
18
|
+
"value"
|
19
|
+
])
|
20
|
+
end
|
21
|
+
|
22
|
+
def native_attribute_aliases
|
23
|
+
super.concat([
|
24
|
+
{
|
25
|
+
existing_entry: {native_key: "id", e_plat_key: "id"}
|
26
|
+
},
|
27
|
+
{
|
28
|
+
existing_entry: {native_key: "key", e_plat_key: "key"}
|
29
|
+
},
|
30
|
+
{
|
31
|
+
existing_entry: {native_key: "value", e_plat_key: "value"}
|
32
|
+
}
|
33
|
+
])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module EPlat
|
2
|
+
class Mapping
|
3
|
+
module Woocommerce
|
4
|
+
module V3
|
5
|
+
class Order
|
6
|
+
class BillingAddress < 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
|
+
"email",
|
23
|
+
"phone"
|
24
|
+
])
|
25
|
+
end
|
26
|
+
|
27
|
+
def native_attribute_aliases
|
28
|
+
super.concat([
|
29
|
+
{
|
30
|
+
alias_attribute: {native_key: "address_1", e_plat_key: "address1"}
|
31
|
+
},
|
32
|
+
{
|
33
|
+
alias_attribute: {native_key: "address_2", e_plat_key: "address2"}
|
34
|
+
},
|
35
|
+
{
|
36
|
+
existing_entry: {native_key: "city", e_plat_key: "city"}
|
37
|
+
},
|
38
|
+
{
|
39
|
+
existing_entry: {native_key: "company", e_plat_key: "company"}
|
40
|
+
},
|
41
|
+
{
|
42
|
+
existing_entry: {native_key: "country", e_plat_key: "country"}
|
43
|
+
},
|
44
|
+
{
|
45
|
+
existing_entry: {native_key: "email", e_plat_key: "email"}
|
46
|
+
},
|
47
|
+
{
|
48
|
+
existing_entry: {native_key: "first_name", e_plat_key: "first_name"}
|
49
|
+
},
|
50
|
+
{
|
51
|
+
existing_entry: {native_key: "last_name", e_plat_key: "last_name"}
|
52
|
+
},
|
53
|
+
{
|
54
|
+
existing_entry: {native_key: "phone", e_plat_key: "phone"}
|
55
|
+
},
|
56
|
+
{
|
57
|
+
alias_attribute: {native_key: "state", e_plat_key: "province"}
|
58
|
+
},
|
59
|
+
{
|
60
|
+
alias_attribute: {native_key: "state", e_plat_key: "province_code"}
|
61
|
+
},
|
62
|
+
{
|
63
|
+
alias_attribute: {native_key: "postcode", e_plat_key: "zip"}
|
64
|
+
},
|
65
|
+
{
|
66
|
+
alias_attribute: {native_key: "country", e_plat_key: "country_code"}
|
67
|
+
},
|
68
|
+
{
|
69
|
+
custom_e_plat_getter: {native_key: nil, e_plat_key: "name", custom_e_plat_getter: "-> (obj) { [obj['first_name'], obj['last_name']].join(' ').strip }"}
|
70
|
+
}
|
71
|
+
# WooCommerce doesn't provide fields for latitude, longitude in billing address
|
72
|
+
])
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module EPlat
|
2
|
+
class Mapping
|
3
|
+
module Woocommerce
|
4
|
+
module V3
|
5
|
+
class Order
|
6
|
+
class LineItem < EPlat::Mapping::Base
|
7
|
+
def native_top_key
|
8
|
+
:itself
|
9
|
+
end
|
10
|
+
|
11
|
+
def native_attributes
|
12
|
+
super.concat([
|
13
|
+
"id",
|
14
|
+
"name",
|
15
|
+
"product_id",
|
16
|
+
"variation_id",
|
17
|
+
"quantity",
|
18
|
+
"tax_class",
|
19
|
+
"subtotal",
|
20
|
+
"subtotal_tax",
|
21
|
+
"total",
|
22
|
+
"total_tax",
|
23
|
+
"taxes",
|
24
|
+
"meta_data",
|
25
|
+
"sku",
|
26
|
+
"price",
|
27
|
+
"parent_name"
|
28
|
+
])
|
29
|
+
end
|
30
|
+
|
31
|
+
def native_attribute_aliases
|
32
|
+
super.concat([
|
33
|
+
{
|
34
|
+
existing_entry: {native_key: "id", e_plat_key: "id"}
|
35
|
+
},
|
36
|
+
{
|
37
|
+
existing_entry: {native_key: "name", e_plat_key: "name"}
|
38
|
+
},
|
39
|
+
{
|
40
|
+
existing_entry: {native_key: "product_id", e_plat_key: "product_id"}
|
41
|
+
},
|
42
|
+
{
|
43
|
+
existing_entry: {native_key: "quantity", e_plat_key: "quantity"}
|
44
|
+
},
|
45
|
+
{
|
46
|
+
alias_attribute: {native_key: "quantity", e_plat_key: "current_quantity"}
|
47
|
+
},
|
48
|
+
{
|
49
|
+
existing_entry: {native_key: "sku", e_plat_key: "sku"}
|
50
|
+
},
|
51
|
+
{
|
52
|
+
existing_entry: {native_key: "price", e_plat_key: "price"}
|
53
|
+
},
|
54
|
+
{
|
55
|
+
existing_entry: {native_key: "name", e_plat_key: "title"}
|
56
|
+
},
|
57
|
+
{
|
58
|
+
alias_attribute: {native_key: "variation_id", e_plat_key: "variant_id"}
|
59
|
+
},
|
60
|
+
{
|
61
|
+
custom_e_plat_getter: {native_key: nil, e_plat_key: "fulfillable_quantity", custom_e_plat_getter: "-> (obj) { obj['quantity'] }"}
|
62
|
+
},
|
63
|
+
{
|
64
|
+
custom_e_plat_getter: {native_key: nil, e_plat_key: "taxable", custom_e_plat_getter: "-> (obj) { !obj['tax_class'].empty? }"}
|
65
|
+
},
|
66
|
+
{
|
67
|
+
custom_e_plat_getter: {native_key: nil, e_plat_key: "requires_shipping", custom_e_plat_getter: "-> (obj) { true }"}
|
68
|
+
},
|
69
|
+
{
|
70
|
+
custom_e_plat_getter: {native_key: nil, e_plat_key: "gift_card", custom_e_plat_getter: "-> (obj) { false }"}
|
71
|
+
},
|
72
|
+
{
|
73
|
+
existing_entry: {native_key: "meta_data", e_plat_key: "properties"}
|
74
|
+
},
|
75
|
+
{
|
76
|
+
existing_entry: {native_key: "taxes", e_plat_key: "tax_lines"}
|
77
|
+
}
|
78
|
+
])
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|