flex_commerce_api 0.6.57

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 (170) hide show
  1. checksums.yaml +7 -0
  2. data/.env.example +6 -0
  3. data/.gitignore +14 -0
  4. data/.rspec +4 -0
  5. data/.rubocop.yml +1065 -0
  6. data/.ruby-gemset +1 -0
  7. data/.ruby-version +1 -0
  8. data/.travis.yml +3 -0
  9. data/Gemfile +4 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +56 -0
  12. data/Rakefile +1 -0
  13. data/app/models/address.rb +41 -0
  14. data/app/models/asset_file.rb +26 -0
  15. data/app/models/asset_folder.rb +14 -0
  16. data/app/models/bundle.rb +20 -0
  17. data/app/models/bundle_group.rb +15 -0
  18. data/app/models/cart.rb +136 -0
  19. data/app/models/category.rb +70 -0
  20. data/app/models/category_tree.rb +11 -0
  21. data/app/models/component.rb +8 -0
  22. data/app/models/container_coupon.rb +12 -0
  23. data/app/models/country.rb +11 -0
  24. data/app/models/coupon.rb +18 -0
  25. data/app/models/customer_account.rb +96 -0
  26. data/app/models/customer_account_authentication.rb +5 -0
  27. data/app/models/customer_segment.rb +6 -0
  28. data/app/models/customer_segment_member.rb +6 -0
  29. data/app/models/data_attribute.rb +6 -0
  30. data/app/models/data_store_record.rb +9 -0
  31. data/app/models/data_store_type.rb +9 -0
  32. data/app/models/discount_summary.rb +12 -0
  33. data/app/models/email.rb +5 -0
  34. data/app/models/ewis_opt_in.rb +8 -0
  35. data/app/models/external_url.rb +6 -0
  36. data/app/models/free_shipping_promotion.rb +12 -0
  37. data/app/models/import.rb +6 -0
  38. data/app/models/import_entry.rb +6 -0
  39. data/app/models/line_item.rb +34 -0
  40. data/app/models/line_item_discount.rb +7 -0
  41. data/app/models/markdown_price.rb +11 -0
  42. data/app/models/menu.rb +36 -0
  43. data/app/models/menu_item.rb +7 -0
  44. data/app/models/menu_item_item.rb +5 -0
  45. data/app/models/note.rb +18 -0
  46. data/app/models/order.rb +38 -0
  47. data/app/models/password_recovery.rb +20 -0
  48. data/app/models/payment_address_verification.rb +13 -0
  49. data/app/models/payment_process.rb +13 -0
  50. data/app/models/payment_provider.rb +15 -0
  51. data/app/models/payment_transaction.rb +13 -0
  52. data/app/models/product.rb +99 -0
  53. data/app/models/product_asset_file.rb +12 -0
  54. data/app/models/promotion.rb +19 -0
  55. data/app/models/promotion_qualifying_product_exclusion.rb +8 -0
  56. data/app/models/redirect.rb +14 -0
  57. data/app/models/refund.rb +14 -0
  58. data/app/models/remote_address.rb +22 -0
  59. data/app/models/remote_line_item.rb +11 -0
  60. data/app/models/remote_order.rb +15 -0
  61. data/app/models/remote_shipping_method.rb +12 -0
  62. data/app/models/report.rb +18 -0
  63. data/app/models/report_invocation.rb +18 -0
  64. data/app/models/retail_store.rb +18 -0
  65. data/app/models/role.rb +6 -0
  66. data/app/models/search_suggestion.rb +17 -0
  67. data/app/models/section.rb +9 -0
  68. data/app/models/session.rb +8 -0
  69. data/app/models/shipping_method.rb +26 -0
  70. data/app/models/slug.rb +19 -0
  71. data/app/models/static_page.rb +60 -0
  72. data/app/models/static_page_folder.rb +8 -0
  73. data/app/models/stock_level.rb +21 -0
  74. data/app/models/tax_code.rb +6 -0
  75. data/app/models/taxonomy.rb +5 -0
  76. data/app/models/template.rb +9 -0
  77. data/app/models/template_component.rb +11 -0
  78. data/app/models/template_definition.rb +12 -0
  79. data/app/models/template_section.rb +12 -0
  80. data/app/models/user.rb +8 -0
  81. data/app/models/user_profile.rb +6 -0
  82. data/app/models/v2/create_order.rb +10 -0
  83. data/app/models/v2/deallocate_order.rb +10 -0
  84. data/app/models/v2/line_item.rb +9 -0
  85. data/app/models/v2/order.rb +9 -0
  86. data/app/models/v2/unallocate_order.rb +10 -0
  87. data/app/models/variant.rb +18 -0
  88. data/app/models/webhook.rb +17 -0
  89. data/app/services/param_to_shql.rb +72 -0
  90. data/app/services/surrogate_keys.rb +44 -0
  91. data/bin/console +14 -0
  92. data/bin/setup +7 -0
  93. data/config/locales/payments.en.yml +3 -0
  94. data/flex-commerce-api.gemspec +41 -0
  95. data/lib/flex_commerce.rb +95 -0
  96. data/lib/flex_commerce_api.rb +21 -0
  97. data/lib/flex_commerce_api/api_base.rb +11 -0
  98. data/lib/flex_commerce_api/base_resource.rb +250 -0
  99. data/lib/flex_commerce_api/config.rb +55 -0
  100. data/lib/flex_commerce_api/error/access_denied.rb +6 -0
  101. data/lib/flex_commerce_api/error/bad_request.rb +10 -0
  102. data/lib/flex_commerce_api/error/base.rb +12 -0
  103. data/lib/flex_commerce_api/error/client_error.rb +7 -0
  104. data/lib/flex_commerce_api/error/connection_error.rb +6 -0
  105. data/lib/flex_commerce_api/error/internal_server.rb +37 -0
  106. data/lib/flex_commerce_api/error/not_found.rb +13 -0
  107. data/lib/flex_commerce_api/error/record_invalid.rb +16 -0
  108. data/lib/flex_commerce_api/error/unexpected_status.rb +7 -0
  109. data/lib/flex_commerce_api/errors.rb +13 -0
  110. data/lib/flex_commerce_api/json_api_client_extension/builder.rb +28 -0
  111. data/lib/flex_commerce_api/json_api_client_extension/capture_surrogate_keys_middleware.rb +16 -0
  112. data/lib/flex_commerce_api/json_api_client_extension/flexible_connection.rb +59 -0
  113. data/lib/flex_commerce_api/json_api_client_extension/has_many_association_proxy.rb +60 -0
  114. data/lib/flex_commerce_api/json_api_client_extension/included_data.rb +27 -0
  115. data/lib/flex_commerce_api/json_api_client_extension/json_format_middleware.rb +20 -0
  116. data/lib/flex_commerce_api/json_api_client_extension/logging_middleware.rb +24 -0
  117. data/lib/flex_commerce_api/json_api_client_extension/paginator.rb +26 -0
  118. data/lib/flex_commerce_api/json_api_client_extension/parse_json.rb +23 -0
  119. data/lib/flex_commerce_api/json_api_client_extension/parsers/parser.rb +16 -0
  120. data/lib/flex_commerce_api/json_api_client_extension/previewed_request_middleware.rb +17 -0
  121. data/lib/flex_commerce_api/json_api_client_extension/remote_builder.rb +29 -0
  122. data/lib/flex_commerce_api/json_api_client_extension/requestor.rb +42 -0
  123. data/lib/flex_commerce_api/json_api_client_extension/save_request_body_middleware.rb +20 -0
  124. data/lib/flex_commerce_api/json_api_client_extension/status_middleware.rb +40 -0
  125. data/lib/flex_commerce_api/v2/api_base.rb +13 -0
  126. data/lib/flex_commerce_api/version.rb +3 -0
  127. data/lib/json_erb.rb +9 -0
  128. data/lib/json_struct.rb +73 -0
  129. data/lib/patches.rb +4 -0
  130. data/lib/patches/json_api_client/resource.rb +50 -0
  131. data/lib/paypal_express.rb +3 -0
  132. data/lib/paypal_express/additional_info.rb +45 -0
  133. data/lib/paypal_express/api.rb +86 -0
  134. data/lib/paypal_express/auth.rb +83 -0
  135. data/lib/paypal_express/cart_shipping_method.rb +38 -0
  136. data/lib/paypal_express/exception/access_denied.rb +10 -0
  137. data/lib/paypal_express/exception/connection_error.rb +10 -0
  138. data/lib/paypal_express/exception/not_authorized.rb +10 -0
  139. data/lib/paypal_express/exception/transaction.rb +15 -0
  140. data/lib/paypal_express/generate_summary.rb +118 -0
  141. data/lib/paypal_express/process/paypal_params.rb +123 -0
  142. data/lib/paypal_express/process/response_parser.rb +146 -0
  143. data/lib/paypal_express/setup.rb +94 -0
  144. data/lib/paypal_express/shipping_methods_for_cart.rb +46 -0
  145. data/lib/retry.rb +20 -0
  146. data/schemas/jsonapi/schema.json +370 -0
  147. data/schemas/shift/v1/documents/collection/address.json +45 -0
  148. data/schemas/shift/v1/documents/collection/asset_file.json +43 -0
  149. data/schemas/shift/v1/documents/collection/asset_folder.json +43 -0
  150. data/schemas/shift/v1/documents/collection/customer_account.json +50 -0
  151. data/schemas/shift/v1/documents/collection/markdown_price.json +43 -0
  152. data/schemas/shift/v1/documents/collection/product.json +43 -0
  153. data/schemas/shift/v1/documents/collection/variant.json +43 -0
  154. data/schemas/shift/v1/documents/member/address.json +39 -0
  155. data/schemas/shift/v1/documents/member/asset_file.json +37 -0
  156. data/schemas/shift/v1/documents/member/asset_folder.json +39 -0
  157. data/schemas/shift/v1/documents/member/customer_account.json +44 -0
  158. data/schemas/shift/v1/documents/member/markdown_price.json +37 -0
  159. data/schemas/shift/v1/documents/member/product.json +39 -0
  160. data/schemas/shift/v1/documents/member/variant.json +46 -0
  161. data/schemas/shift/v1/resources/address.json +130 -0
  162. data/schemas/shift/v1/resources/asset_file.json +146 -0
  163. data/schemas/shift/v1/resources/asset_folder.json +188 -0
  164. data/schemas/shift/v1/resources/customer_account.json +339 -0
  165. data/schemas/shift/v1/resources/markdown_price.json +52 -0
  166. data/schemas/shift/v1/resources/product.json +230 -0
  167. data/schemas/shift/v1/resources/variant.json +298 -0
  168. data/tasks/json_schema.thor +275 -0
  169. data/todo.md +8 -0
  170. metadata +470 -0
@@ -0,0 +1,12 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ #
4
+ # A flex commerce ContainerCoupon model
5
+ #
6
+ #
7
+ class ContainerCoupon < FlexCommerceApi::ApiBase
8
+ has_one :promotion, class_name: "FlexCommerce::Promotion"
9
+ belongs_to :order, class_name: "FlexCommerce::Order"
10
+
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ #
4
+ # A flex commerce Country model
5
+ #
6
+ #
7
+ #
8
+ class Country < FlexCommerceApi::ApiBase
9
+
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ #
4
+ # A flex commerce Coupon model
5
+ #
6
+ # A coupon can be created with a cart id the path
7
+ #
8
+ # It is used much like an active record model.
9
+ #
10
+ # Examples:
11
+ #
12
+ # FlexCommerce::Coupon.create(coupon_code: "coupon1", path: { cart_id: current_cart.id })
13
+ #
14
+ class Coupon < FlexCommerceApi::ApiBase
15
+ belongs_to :cart, class_name: "FlexCommerce::Cart"
16
+
17
+ end
18
+ end
@@ -0,0 +1,96 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ #
4
+ # A flex commerce Customer Account model
5
+ #
6
+ # This model provides access to the flex commerce customer account and associated cart.
7
+ # It is used much like an active record model.
8
+ #
9
+ # Examples:
10
+ #
11
+ #
12
+ #
13
+ # # Creating an account
14
+ #
15
+ # FlexCommerce::CustomerAccount.create #creates and returns a new account ready for use
16
+ #
17
+ # # Fetching its cart
18
+ #
19
+ # account.cart
20
+ #
21
+ # # Finding an account
22
+ #
23
+ # FlexCommerce::CustomerAccount.find(<<customer_account_id>>) # Finds the account with this unique id
24
+ #
25
+ #
26
+ class CustomerAccount < FlexCommerceApi::ApiBase
27
+ # @method find
28
+ # @param [String] spec
29
+ # Finds an account
30
+ # @return [FlexCommerce::CustomerAccount] customer_account The customer account
31
+ # @raise [FlexCommerceApi::Error::NotFound] If not found
32
+
33
+ # @method cart
34
+ # Provides access to the customers cart
35
+ # @return FlexCommerce::Cart
36
+
37
+ # @TODO Document other popular methods that we will support
38
+
39
+ has_one :cart, class_name: "::FlexCommerce::Cart"
40
+ has_many :addresses, class_name: "::FlexCommerce::Address"
41
+ has_many :customer_segments, class_name: "::FlexCommerce::CustomerSegment"
42
+ has_many :notes, class_name: "::FlexCommerce::Note"
43
+ has_many :orders, class_name: "::FlexCommerce::RemoteOrder"
44
+ has_one :password_recovery, class_name: "::FlexCommerce::PasswordRecovery"
45
+
46
+ property :email, type: :string
47
+ property :reference, type: :string
48
+ property :password, type: :string
49
+
50
+
51
+ def self.authenticate(attributes = {})
52
+ FlexCommerce::CustomerAccountAuthentication.create(attributes).customer_account
53
+ rescue ::FlexCommerceApi::Error::NotFound
54
+ nil
55
+ end
56
+
57
+ def self.find_by_email(email)
58
+ requestor.custom("email:#{URI.encode_www_form_component(email)}", {request_method: :get}, {}).first
59
+ rescue ::FlexCommerceApi::Error::NotFound
60
+ nil
61
+ end
62
+
63
+ def self.find_by_reference(reference)
64
+ requestor.custom("reference:#{reference}", {request_method: :get}, {}).first
65
+ rescue ::FlexCommerceApi::Error::NotFound
66
+ nil
67
+ end
68
+
69
+ # Find customer account by password reset token provided in email's link
70
+ # Used in reset password scenario
71
+ def self.find_by_token(token)
72
+ requestor.custom("token:#{token}", {request_method: :get}, {}).first
73
+ rescue ::FlexCommerceApi::Error::NotFound
74
+ nil
75
+ end
76
+
77
+ def generate_token(attributes)
78
+ ::FlexCommerce::PasswordRecovery.create(attributes.merge(customer_account_id: id))
79
+ end
80
+
81
+ def reset_password(attributes)
82
+ password_recovery.id = nil # because it is singletone resource, otherwise id is injected into path
83
+ password_recovery.update(attributes.merge(customer_account_id: id))
84
+ password_recovery
85
+ end
86
+
87
+ def orders
88
+ return super if relationships[:orders].key?("data")
89
+ get_related(:orders)
90
+ end
91
+
92
+ def create_note(attributes = {})
93
+ ::FlexCommerce::Note.create(attributes.merge(attached_to_id: self.id, attached_to_type: self.class.name.demodulize))
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,5 @@
1
+ module FlexCommerce
2
+ class CustomerAccountAuthentication < FlexCommerceApi::ApiBase
3
+
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ class CustomerSegment < FlexCommerceApi::ApiBase
4
+ has_many :customer_segment_members
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ class CustomerSegmentMember < FlexCommerceApi::ApiBase
4
+ has_one :customer_segment
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ require "flex_commerce_api/api_base"
2
+
3
+ module FlexCommerce
4
+ class DataAttribute < FlexCommerceApi::ApiBase
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ require "flex_commerce_api/api_base"
2
+
3
+ module FlexCommerce
4
+ class DataStoreRecord < FlexCommerceApi::ApiBase
5
+ def self.table_name
6
+ 'generic_data_store/records'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require "flex_commerce_api/api_base"
2
+
3
+ module FlexCommerce
4
+ class DataStoreType < FlexCommerceApi::ApiBase
5
+ def self.table_name
6
+ 'generic_data_store/record_types'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ #
4
+ # A flex commerce discount summary model
5
+ #
6
+ # This model is used by the Cart model as an association so is not
7
+ # usable directly on the API as there is no corresponding URL
8
+ #
9
+ #
10
+ class DiscountSummary < FlexCommerceApi::ApiBase
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ class Email < FlexCommerceApi::ApiBase
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+
4
+ # A flex commerce Email When In Stock (EWIS) model
5
+
6
+ class EwisOptIn < FlexCommerceApi::ApiBase
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ require "flex_commerce_api/api_base"
2
+
3
+ module FlexCommerce
4
+ class ExternalUrl < FlexCommerceApi::ApiBase
5
+ end
6
+ end
@@ -0,0 +1,12 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ #
4
+ # A flex Free Shipping Promotion summary model
5
+ #
6
+ # This model is used by the Cart model as an association so is not
7
+ # usable directly on the API as there is no corresponding URL
8
+ #
9
+ #
10
+ class FreeShippingPromotion < FlexCommerceApi::ApiBase
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ class Import < FlexCommerceApi::ApiBase
4
+ has_many :import_entries, class_name: "FlexCommerce::ImportEntry"
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ class ImportEntry < FlexCommerceApi::ApiBase
4
+ belongs_to :import, class_name: "FlexCommerce::Import"
5
+ end
6
+ end
@@ -0,0 +1,34 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ #
4
+ # A flex commerce LineItem model
5
+ #
6
+ # This model provides access to the flex commerce cart's line_items.
7
+ # This model allows you to create a line_item, update its contents, delete a line_item or list the line items for a specific cart.
8
+ #
9
+ # It is used much like an active record model.
10
+ #
11
+ # Examples:
12
+ #
13
+ #
14
+ #
15
+ # # Creating a line item for a specific cart
16
+ #
17
+ # FlexCommerce::LineItem.create container: cart, item: variant, unit_quantity: 3 #creates and returns a new line item ready for use
18
+ #
19
+ class LineItem < FlexCommerceApi::ApiBase
20
+
21
+ # @method item
22
+ # The item (either a variant or a bundle)
23
+ # @return [FlexCommerce::Variant|FlexCommerce::Bundle]
24
+
25
+ # @TODO Document other popular methods that we will support
26
+
27
+ has_one :item
28
+ belongs_to :cart, class_name: "::FlexCommerce::Cart"
29
+
30
+
31
+ # note: only embedded in order responses, not carts
32
+ has_many :line_item_discounts, class_name: "::FlexCommerce::LineItemDiscount"
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ require "flex_commerce_api/api_base"
2
+
3
+ module FlexCommerce
4
+ class LineItemDiscount < FlexCommerceApi::ApiBase
5
+ has_one :promotion, class_name: "::FlexCommerce::Promotion"
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ require "flex_commerce_api/api_base"
2
+
3
+ module FlexCommerce
4
+ class MarkdownPrice < FlexCommerceApi::ApiBase
5
+ belongs_to :variant
6
+
7
+ def active?
8
+ Time.now.between?(start_at, end_at)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,36 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ #
4
+ # A flex commerce Menu model
5
+ #
6
+ # This model provides access to the flex commerce menus.
7
+ # As managing the menus is the job of the administration panel, this
8
+ # model is read only.
9
+ #
10
+ # It is used much like an active record model.
11
+ #
12
+ # Examples:
13
+ #
14
+ #
15
+ #
16
+ # # Fetching all menus
17
+ #
18
+ # FlexCommerce::Menu.all #fetches all menus(actually the first page in case there are thousands)
19
+ #
20
+ # # Finding a specific menu
21
+ #
22
+ # FlexCommerce::Menu.find("my-menu-reference") # Finds the menu with this unique id
23
+ #
24
+ # # Finding nested menu items of the menu (See MenuItem class for what you can do with this including getting nested menu items)
25
+ #
26
+ # FlexCommerce::Menu.find("my-product-slug").menu_items
27
+ #
28
+ #
29
+ class Menu < FlexCommerceApi::ApiBase
30
+ has_many :menu_items
31
+ # This model has a path attribute so path can no longer be used to modify the path
32
+ def self.path(params = nil, record = nil)
33
+ super(params.nil? ? nil : params.except("path"), record)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,7 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ class MenuItem < FlexCommerceApi::ApiBase
4
+ belongs_to :menu, class_name: "::FlexCommerce::Menu"
5
+ has_many :menu_items
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ class MenuItemItem < FlexCommerceApi::ApiBase
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ require "flex_commerce_api/api_base"
2
+ #
3
+ # A flex commerce Note model
4
+ #
5
+ # This model provides access to flex commerce notes
6
+ #
7
+ # It is used much like an active record model.
8
+ #
9
+ # Examples:
10
+ #
11
+ # # Fetching notes for a specific customer account
12
+ # FlexCommerce::Note.where(customer_account_id: 1).all
13
+ #
14
+ module FlexCommerce
15
+ class Note < FlexCommerceApi::ApiBase
16
+ # @TODO Document popular methods that we will support
17
+ end
18
+ end
@@ -0,0 +1,38 @@
1
+ require "flex_commerce_api/api_base"
2
+
3
+ module FlexCommerce
4
+ #
5
+ # A flex commerce Order model
6
+ #
7
+ # This model provides access to the flex commerce order
8
+ #
9
+ #
10
+ #
11
+ class Order < FlexCommerceApi::ApiBase
12
+ has_many :transactions, class_name: "::FlexCommerce::OrderTransaction"
13
+ has_many :line_items, class_name: "::FlexCommerce::LineItem"
14
+ has_many :coupons, class_name: "::FlexCommerce::ContainerCoupon"
15
+ has_one :shipping_promotion, class_name: "::FlexCommerce::Promotion"
16
+ has_one :shipping_address, class_name: "::FlexCommerce::Address"
17
+ has_one :billing_address, class_name: "::FlexCommerce::Address"
18
+
19
+ def self.path(params = nil, record = nil)
20
+ if params && params[:filter] && (customer_id = params[:filter].delete(:customer_account_id))
21
+ File.join("customer_accounts/%d" % customer_id, super)
22
+ else
23
+ super
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+ def self.create(attributes = {})
30
+ super(attributes.merge(extra_attributes))
31
+ end
32
+
33
+ def self.extra_attributes
34
+ extras = {}
35
+ extras.merge!(test: true) if FlexCommerceApi.config.order_test_mode
36
+ extras
37
+ end
38
+ end
@@ -0,0 +1,20 @@
1
+ require "flex_commerce_api/api_base"
2
+ module FlexCommerce
3
+ #
4
+ # A flex commerce Password Recovery model
5
+ #
6
+ # This model provides access to the flex commerce customer account password recovery functionality.
7
+ # It is used much like an active record model.
8
+
9
+ class PasswordRecovery < FlexCommerceApi::ApiBase
10
+ belongs_to :customer_account, class_name: "::FlexCommerce::CustomerAccount"
11
+
12
+ def self.path(params, *args)
13
+ # Since it is singletone resource, use singular name in path and remove id
14
+ params.delete(:id)
15
+ path = super.gsub(table_name, resource_name)
16
+ params.delete(:customer_account_id)
17
+ path
18
+ end
19
+ end
20
+ end