walmart-apimatic-sdk 0.0.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 +7 -0
- data/LICENSE +28 -0
- data/README.md +176 -0
- data/bin/console +15 -0
- data/lib/walmart_ap_is/api_helper.rb +10 -0
- data/lib/walmart_ap_is/apis/base_api.rb +67 -0
- data/lib/walmart_ap_is/apis/cppreference_api.rb +60 -0
- data/lib/walmart_ap_is/apis/detail_api.rb +58 -0
- data/lib/walmart_ap_is/apis/feeds_api.rb +79 -0
- data/lib/walmart_ap_is/apis/feeds_feed_type_incentive_enrollment_api.rb +66 -0
- data/lib/walmart_ap_is/apis/feeds_feed_type_price_and_promotion_api.rb +86 -0
- data/lib/walmart_ap_is/apis/feeds_feed_type_walmart_funded_incentives_enrollment_api.rb +75 -0
- data/lib/walmart_ap_is/apis/get_pricing_insights_api.rb +60 -0
- data/lib/walmart_ap_is/apis/incentives_api.rb +93 -0
- data/lib/walmart_ap_is/apis/m_strategy_collection_id_api.rb +118 -0
- data/lib/walmart_ap_is/apis/misc_api.rb +23 -0
- data/lib/walmart_ap_is/apis/price_api.rb +63 -0
- data/lib/walmart_ap_is/apis/repricer_feeds_api.rb +64 -0
- data/lib/walmart_ap_is/apis/strategies_api.rb +56 -0
- data/lib/walmart_ap_is/apis/strategy_api.rb +63 -0
- data/lib/walmart_ap_is/apis/token_api.rb +98 -0
- data/lib/walmart_ap_is/apis/wfpreference_api.rb +68 -0
- data/lib/walmart_ap_is/client.rb +163 -0
- data/lib/walmart_ap_is/configuration.rb +165 -0
- data/lib/walmart_ap_is/exceptions/api_exception.rb +21 -0
- data/lib/walmart_ap_is/http/api_response.rb +19 -0
- data/lib/walmart_ap_is/http/auth/basic_auth.rb +62 -0
- data/lib/walmart_ap_is/http/http_call_back.rb +10 -0
- data/lib/walmart_ap_is/http/http_method_enum.rb +10 -0
- data/lib/walmart_ap_is/http/http_request.rb +10 -0
- data/lib/walmart_ap_is/http/http_response.rb +10 -0
- data/lib/walmart_ap_is/http/proxy_settings.rb +22 -0
- data/lib/walmart_ap_is/logging/configuration/api_logging_configuration.rb +186 -0
- data/lib/walmart_ap_is/logging/sdk_logger.rb +17 -0
- data/lib/walmart_ap_is/models/assign_unassign_items_to_from_repricer_strategy_request.rb +92 -0
- data/lib/walmart_ap_is/models/base_model.rb +110 -0
- data/lib/walmart_ap_is/models/client_credentials_res.rb +82 -0
- data/lib/walmart_ap_is/models/create_repricer_strategy_request.rb +149 -0
- data/lib/walmart_ap_is/models/current_price.rb +82 -0
- data/lib/walmart_ap_is/models/filter.rb +90 -0
- data/lib/walmart_ap_is/models/get_pricing_insights_request.rb +109 -0
- data/lib/walmart_ap_is/models/incentives_enrollment.rb +95 -0
- data/lib/walmart_ap_is/models/item.rb +239 -0
- data/lib/walmart_ap_is/models/item1.rb +73 -0
- data/lib/walmart_ap_is/models/item_feed_header.rb +119 -0
- data/lib/walmart_ap_is/models/item_identifiers.rb +72 -0
- data/lib/walmart_ap_is/models/item_price_response.rb +90 -0
- data/lib/walmart_ap_is/models/json1.rb +73 -0
- data/lib/walmart_ap_is/models/mp_item.rb +74 -0
- data/lib/walmart_ap_is/models/mp_item_feed_header.rb +91 -0
- data/lib/walmart_ap_is/models/page_context.rb +102 -0
- data/lib/walmart_ap_is/models/pricing.rb +84 -0
- data/lib/walmart_ap_is/models/pricing_insights_response_list.rb +328 -0
- data/lib/walmart_ap_is/models/program_action.rb +83 -0
- data/lib/walmart_ap_is/models/program_action1.rb +83 -0
- data/lib/walmart_ap_is/models/program_action_feed_header.rb +147 -0
- data/lib/walmart_ap_is/models/programs.rb +80 -0
- data/lib/walmart_ap_is/models/programs1.rb +75 -0
- data/lib/walmart_ap_is/models/promo_discount.rb +90 -0
- data/lib/walmart_ap_is/models/refresh_token_res.rb +82 -0
- data/lib/walmart_ap_is/models/scopes.rb +142 -0
- data/lib/walmart_ap_is/models/search_criteria.rb +82 -0
- data/lib/walmart_ap_is/models/set_up_cap_sku_all_legacy_request.rb +85 -0
- data/lib/walmart_ap_is/models/sort.rb +82 -0
- data/lib/walmart_ap_is/models/status_info.rb +85 -0
- data/lib/walmart_ap_is/models/strategy.rb +94 -0
- data/lib/walmart_ap_is/models/strategy5.rb +106 -0
- data/lib/walmart_ap_is/models/strategy_collection.rb +169 -0
- data/lib/walmart_ap_is/models/successful_operation.rb +159 -0
- data/lib/walmart_ap_is/models/successful_operation1.rb +73 -0
- data/lib/walmart_ap_is/models/successful_operation11.rb +82 -0
- data/lib/walmart_ap_is/models/successful_operation12.rb +82 -0
- data/lib/walmart_ap_is/models/successful_operation2.rb +100 -0
- data/lib/walmart_ap_is/models/successful_operation3.rb +92 -0
- data/lib/walmart_ap_is/models/successful_operation4.rb +84 -0
- data/lib/walmart_ap_is/models/successful_operation5.rb +91 -0
- data/lib/walmart_ap_is/models/successful_operation6.rb +93 -0
- data/lib/walmart_ap_is/models/successful_operation7.rb +75 -0
- data/lib/walmart_ap_is/models/successful_operation8.rb +73 -0
- data/lib/walmart_ap_is/models/token_api_authorization_code.rb +122 -0
- data/lib/walmart_ap_is/models/token_api_client_credentials.rb +122 -0
- data/lib/walmart_ap_is/models/token_api_refresh_token.rb +122 -0
- data/lib/walmart_ap_is/models/token_api_res.rb +82 -0
- data/lib/walmart_ap_is/models/update_pricing_for_a_single_item_request.rb +91 -0
- data/lib/walmart_ap_is/models/update_pricing_for_multiple_items_in_bulk_new_request.rb +92 -0
- data/lib/walmart_ap_is/models/update_reduced_referral_fee_incentives_enrollment_request.rb +95 -0
- data/lib/walmart_ap_is/models/update_repricer_strategy_request.rb +149 -0
- data/lib/walmart_ap_is/models/update_walmart_funded_incentives_enrollment_for_specific_items_request.rb +95 -0
- data/lib/walmart_ap_is/models/value.rb +91 -0
- data/lib/walmart_ap_is/models/value1.rb +101 -0
- data/lib/walmart_ap_is/models/walmart_funded_incentives_enrollment.rb +79 -0
- data/lib/walmart_ap_is/models/xml1.rb +73 -0
- data/lib/walmart_ap_is/utilities/date_time_helper.rb +11 -0
- data/lib/walmart_ap_is/utilities/file_wrapper.rb +28 -0
- data/lib/walmart_ap_is.rb +122 -0
- metadata +179 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# walmart_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WalmartApIs
|
|
7
|
+
# TokenApi
|
|
8
|
+
class TokenApi < BaseApi
|
|
9
|
+
# Obtain access tokens for API authentication using OAuth 2.0 by providing
|
|
10
|
+
# Client ID and Client Secret. This endpoint supports multiple grant types
|
|
11
|
+
# for different authentication scenarios - Client Credentials Grant,
|
|
12
|
+
# Authorization Code Grant, Refresh Token Grant.
|
|
13
|
+
# An access token expires after a certain interval, so you will have to
|
|
14
|
+
# refresh a user's access token. You could use refresh token, obtained from
|
|
15
|
+
# the token API call using authorization code grant type, to get a new
|
|
16
|
+
# access token. <b>Token Lifetimes</b><br /><ul><li><b>Access Token:</b> 15
|
|
17
|
+
# minutes (900 seconds)</li><li><b>Refresh Token:</b> 1 year (365
|
|
18
|
+
# days)</li></ul><br /> <a
|
|
19
|
+
# href="https://developer.walmart.com/us-marketplace/docs/get-an-access-toke
|
|
20
|
+
# n">Get an access token using Token API</a>
|
|
21
|
+
# <a
|
|
22
|
+
# href="https://developer.walmart.com/us-marketplace/docs/get-started-as-a-s
|
|
23
|
+
# eller">Get started as a seller</a>
|
|
24
|
+
# <a
|
|
25
|
+
# href="https://developer.walmart.com/us-marketplace/docs/get-started-as-a-s
|
|
26
|
+
# olution-provider">Get started as a solution provider</a>
|
|
27
|
+
# <a
|
|
28
|
+
# href="https://developer.walmart.com/us-marketplace/docs/oauth-20-authoriza
|
|
29
|
+
# tion">OAuth2.0 authorization</a>
|
|
30
|
+
# @param [Integer] wm_partner_id Required parameter: Partner ID registered
|
|
31
|
+
# in Walmart marketplace to identify a seller account. <br /> This field is
|
|
32
|
+
# required when `grant_type` is `authorization_code` or `refresh_token`.
|
|
33
|
+
# @param [String] wm_consumer_channel_type Required parameter: A unique ID
|
|
34
|
+
# to track the consumer request by channel. Use the Consumer Channel Type
|
|
35
|
+
# received during onboarding.
|
|
36
|
+
# @param [String] wm_qos_correlation_id Required parameter: A unique ID that
|
|
37
|
+
# identifies each API call and is used to track and debug issues. Use a
|
|
38
|
+
# randomly generated GUID for this ID.
|
|
39
|
+
# @param [String] wm_svc_name Required parameter: Specifies the name of the
|
|
40
|
+
# Walmart service being called.
|
|
41
|
+
# @param [String] accept Required parameter: TODO: type description here
|
|
42
|
+
# @param [String] grant_type Required parameter: Type of OAuth2.0 grant
|
|
43
|
+
# requested. <br /> **Available grant types:** `authorization_code`,
|
|
44
|
+
# `refresh_token` and `client_credentials`
|
|
45
|
+
# @param [String] code Required parameter: Authorization code returned to
|
|
46
|
+
# your redirect URI, obtained by your client app when the seller authorizes
|
|
47
|
+
# your app to access the seller resource. <br /> This field is required when
|
|
48
|
+
# **grant_type: authorization_code**.
|
|
49
|
+
# @param [String] redirect_uri Required parameter: Redirect URI must exactly
|
|
50
|
+
# match one of the URIs registered for your client app, which was provided
|
|
51
|
+
# while registering the app. <br /> This field is required when
|
|
52
|
+
# **grant_type: authorization_code**.
|
|
53
|
+
# @param [String] refresh_token Required parameter: Refresh token received
|
|
54
|
+
# as response of Authentication API with authorization_code grant type. Use
|
|
55
|
+
# it to exchange for a new access token when the current one expires. <br />
|
|
56
|
+
# This field is required when **grant_type: refresh_token**.
|
|
57
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
58
|
+
def token_api(wm_partner_id,
|
|
59
|
+
wm_consumer_channel_type,
|
|
60
|
+
wm_qos_correlation_id,
|
|
61
|
+
wm_svc_name,
|
|
62
|
+
accept,
|
|
63
|
+
grant_type,
|
|
64
|
+
code,
|
|
65
|
+
redirect_uri,
|
|
66
|
+
refresh_token)
|
|
67
|
+
@api_call
|
|
68
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
|
69
|
+
'/token',
|
|
70
|
+
Server::SERVER_1)
|
|
71
|
+
.header_param(new_parameter(wm_partner_id, key: 'WM_PARTNER.ID')
|
|
72
|
+
.is_required(true))
|
|
73
|
+
.header_param(new_parameter(wm_consumer_channel_type, key: 'WM_CONSUMER.CHANNEL.TYPE')
|
|
74
|
+
.is_required(true))
|
|
75
|
+
.header_param(new_parameter(wm_qos_correlation_id, key: 'WM_QOS.CORRELATION_ID')
|
|
76
|
+
.is_required(true))
|
|
77
|
+
.header_param(new_parameter(wm_svc_name, key: 'WM_SVC.NAME')
|
|
78
|
+
.is_required(true))
|
|
79
|
+
.header_param(new_parameter(accept, key: 'Accept')
|
|
80
|
+
.is_required(true))
|
|
81
|
+
.form_param(new_parameter(grant_type, key: 'grant_type')
|
|
82
|
+
.is_required(true))
|
|
83
|
+
.form_param(new_parameter(code, key: 'code')
|
|
84
|
+
.is_required(true))
|
|
85
|
+
.form_param(new_parameter(redirect_uri, key: 'redirect_uri')
|
|
86
|
+
.is_required(true))
|
|
87
|
+
.form_param(new_parameter(refresh_token, key: 'refresh_token')
|
|
88
|
+
.is_required(true))
|
|
89
|
+
.header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
|
|
90
|
+
.auth(Single.new('basic')))
|
|
91
|
+
.response(new_response_handler
|
|
92
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
93
|
+
.deserialize_into(TokenApiClientCredentials.method(:from_hash))
|
|
94
|
+
.is_api_response(true))
|
|
95
|
+
.execute
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# walmart_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WalmartApIs
|
|
7
|
+
# WfpreferenceApi
|
|
8
|
+
class WfpreferenceApi < BaseApi
|
|
9
|
+
# Updates the enrollment status of all items in the Walmart-funded
|
|
10
|
+
# incentives program. By default, all items are auto-enrolled in
|
|
11
|
+
# Walmart-funded incentives, meaning that eligible items are automatically
|
|
12
|
+
# included in these programs to benefit from price reductions funded by
|
|
13
|
+
# Walmart.
|
|
14
|
+
# If you wish to permanently turn off Walmart-funded incentives for all
|
|
15
|
+
# items in your catalog, you can use this API to set the Walmart-funded
|
|
16
|
+
# incentives program status to `OFF`. The default value of this variable is
|
|
17
|
+
# `ON`. Any changes to preferences will lock in (disable) the preference
|
|
18
|
+
# option for a period of 4 hours, as indicated by the `isDisabled` response
|
|
19
|
+
# field of the API.
|
|
20
|
+
# For more information and usage examples, refer to the <a
|
|
21
|
+
# href="https://developer.walmart.com/us-marketplace/docs/manage-enrollment-
|
|
22
|
+
# all-items-in-walmart-funded-incentives">Pricing API Guide</a>
|
|
23
|
+
# @param [TrueClass | FalseClass] auto_enroll_enabled Required parameter:
|
|
24
|
+
# Specify the boolean for enabling auto enrollment. Examples of the allowed
|
|
25
|
+
# values are `true` or `false`.
|
|
26
|
+
# @param [String] wm_sec_access_token Required parameter: Access token
|
|
27
|
+
# obtained from the Token API. This is required for authenticating requests
|
|
28
|
+
# to Walmart Marketplace APIs.
|
|
29
|
+
# @param [String] wm_consumer_channel_type Required parameter: A unique ID
|
|
30
|
+
# to identify the consumer request by channel. Use the Consumer Channel Type
|
|
31
|
+
# received during onboarding.
|
|
32
|
+
# @param [String] wm_qos_correlation_id Required parameter: A unique ID that
|
|
33
|
+
# identifies each API call and is used to track and debug issues. Use a
|
|
34
|
+
# randomly generated GUID for this ID.
|
|
35
|
+
# @param [String] wm_svc_name Required parameter: Specifies the name of the
|
|
36
|
+
# Walmart service being called.
|
|
37
|
+
# @param [String] accept Required parameter: TODO: type description here
|
|
38
|
+
# @return [ApiResponse] Complete http response with raw body and status code.
|
|
39
|
+
def update_walmart_funded_incentives_enrollment_for_all_items(auto_enroll_enabled,
|
|
40
|
+
wm_sec_access_token,
|
|
41
|
+
wm_consumer_channel_type,
|
|
42
|
+
wm_qos_correlation_id,
|
|
43
|
+
wm_svc_name,
|
|
44
|
+
accept)
|
|
45
|
+
@api_call
|
|
46
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
|
47
|
+
'/price/incentives/wfpreference',
|
|
48
|
+
Server::SERVER_1)
|
|
49
|
+
.query_param(new_parameter(auto_enroll_enabled, key: 'autoEnrollEnabled')
|
|
50
|
+
.is_required(true))
|
|
51
|
+
.header_param(new_parameter(wm_sec_access_token, key: 'WM_SEC.ACCESS_TOKEN')
|
|
52
|
+
.is_required(true))
|
|
53
|
+
.header_param(new_parameter(wm_consumer_channel_type, key: 'WM_CONSUMER.CHANNEL.TYPE')
|
|
54
|
+
.is_required(true))
|
|
55
|
+
.header_param(new_parameter(wm_qos_correlation_id, key: 'WM_QOS.CORRELATION_ID')
|
|
56
|
+
.is_required(true))
|
|
57
|
+
.header_param(new_parameter(wm_svc_name, key: 'WM_SVC.NAME')
|
|
58
|
+
.is_required(true))
|
|
59
|
+
.header_param(new_parameter(accept, key: 'Accept')
|
|
60
|
+
.is_required(true)))
|
|
61
|
+
.response(new_response_handler
|
|
62
|
+
.deserializer(APIHelper.method(:custom_type_deserializer))
|
|
63
|
+
.deserialize_into(SuccessfulOperation4.method(:from_hash))
|
|
64
|
+
.is_api_response(true))
|
|
65
|
+
.execute
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# walmart_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WalmartApIs
|
|
7
|
+
# walmart_ap_is client class.
|
|
8
|
+
class Client
|
|
9
|
+
include CoreLibrary
|
|
10
|
+
attr_reader :config, :auth_managers
|
|
11
|
+
|
|
12
|
+
def user_agent_detail
|
|
13
|
+
config.user_agent_detail
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Access to m_strategy_collection_id controller.
|
|
17
|
+
# @return [MStrategyCollectionIdApi] Returns the controller instance.
|
|
18
|
+
def m_strategy_collection_id
|
|
19
|
+
@m_strategy_collection_id ||= MStrategyCollectionIdApi.new @global_configuration
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Access to strategy controller.
|
|
23
|
+
# @return [StrategyApi] Returns the controller instance.
|
|
24
|
+
def strategy
|
|
25
|
+
@strategy ||= StrategyApi.new @global_configuration
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Access to strategies controller.
|
|
29
|
+
# @return [StrategiesApi] Returns the controller instance.
|
|
30
|
+
def strategies
|
|
31
|
+
@strategies ||= StrategiesApi.new @global_configuration
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Access to wfpreference controller.
|
|
35
|
+
# @return [WfpreferenceApi] Returns the controller instance.
|
|
36
|
+
def wfpreference
|
|
37
|
+
@wfpreference ||= WfpreferenceApi.new @global_configuration
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Access to incentives controller.
|
|
41
|
+
# @return [IncentivesApi] Returns the controller instance.
|
|
42
|
+
def incentives
|
|
43
|
+
@incentives ||= IncentivesApi.new @global_configuration
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Access to get_pricing_insights controller.
|
|
47
|
+
# @return [GetPricingInsightsApi] Returns the controller instance.
|
|
48
|
+
def get_pricing_insights
|
|
49
|
+
@get_pricing_insights ||= GetPricingInsightsApi.new @global_configuration
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Access to price controller.
|
|
53
|
+
# @return [PriceApi] Returns the controller instance.
|
|
54
|
+
def price
|
|
55
|
+
@price ||= PriceApi.new @global_configuration
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Access to repricer_feeds controller.
|
|
59
|
+
# @return [RepricerFeedsApi] Returns the controller instance.
|
|
60
|
+
def repricer_feeds
|
|
61
|
+
@repricer_feeds ||= RepricerFeedsApi.new @global_configuration
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Access to feeds controller.
|
|
65
|
+
# @return [FeedsApi] Returns the controller instance.
|
|
66
|
+
def feeds
|
|
67
|
+
@feeds ||= FeedsApi.new @global_configuration
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Access to feeds_feed_type_price_and_promotion controller.
|
|
71
|
+
# @return [FeedsFeedTypePriceAndPromotionApi] Returns the controller instance.
|
|
72
|
+
def feeds_feed_type_price_and_promotion
|
|
73
|
+
@feeds_feed_type_price_and_promotion ||= FeedsFeedTypePriceAndPromotionApi.new @global_configuration
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Access to feeds_feed_type_walmart_funded_incentives_enrollment controller.
|
|
77
|
+
# @return [FeedsFeedTypeWalmartFundedIncentivesEnrollmentApi] Returns the controller instance.
|
|
78
|
+
def feeds_feed_type_walmart_funded_incentives_enrollment
|
|
79
|
+
@feeds_feed_type_walmart_funded_incentives_enrollment ||= FeedsFeedTypeWalmartFundedIncentivesEnrollmentApi.new @global_configuration
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Access to feeds_feed_type_incentive_enrollment controller.
|
|
83
|
+
# @return [FeedsFeedTypeIncentiveEnrollmentApi] Returns the controller instance.
|
|
84
|
+
def feeds_feed_type_incentive_enrollment
|
|
85
|
+
@feeds_feed_type_incentive_enrollment ||= FeedsFeedTypeIncentiveEnrollmentApi.new @global_configuration
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Access to cppreference controller.
|
|
89
|
+
# @return [CppreferenceApi] Returns the controller instance.
|
|
90
|
+
def cppreference
|
|
91
|
+
@cppreference ||= CppreferenceApi.new @global_configuration
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Access to detail controller.
|
|
95
|
+
# @return [DetailApi] Returns the controller instance.
|
|
96
|
+
def detail
|
|
97
|
+
@detail ||= DetailApi.new @global_configuration
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Access to token controller.
|
|
101
|
+
# @return [TokenApi] Returns the controller instance.
|
|
102
|
+
def token
|
|
103
|
+
@token ||= TokenApi.new @global_configuration
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Access to misc controller.
|
|
107
|
+
# @return [MiscApi] Returns the controller instance.
|
|
108
|
+
def misc
|
|
109
|
+
@misc ||= MiscApi.new @global_configuration
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def initialize(
|
|
113
|
+
connection: nil, adapter: :net_http_persistent, timeout: 30,
|
|
114
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
|
115
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
|
116
|
+
retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
|
|
117
|
+
logging_configuration: nil, environment: Environment::PRODUCTION,
|
|
118
|
+
basic_auth_credentials: nil, config: nil
|
|
119
|
+
)
|
|
120
|
+
@config = if config.nil?
|
|
121
|
+
Configuration.new(
|
|
122
|
+
connection: connection, adapter: adapter, timeout: timeout,
|
|
123
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
|
124
|
+
backoff_factor: backoff_factor,
|
|
125
|
+
retry_statuses: retry_statuses,
|
|
126
|
+
retry_methods: retry_methods, http_callback: http_callback,
|
|
127
|
+
proxy_settings: proxy_settings,
|
|
128
|
+
logging_configuration: logging_configuration,
|
|
129
|
+
environment: environment,
|
|
130
|
+
basic_auth_credentials: basic_auth_credentials
|
|
131
|
+
)
|
|
132
|
+
else
|
|
133
|
+
config
|
|
134
|
+
end
|
|
135
|
+
user_agent_params = BaseApi.user_agent_parameters
|
|
136
|
+
|
|
137
|
+
@global_configuration = GlobalConfiguration.new(client_configuration: @config)
|
|
138
|
+
.base_uri_executor(@config.method(:get_base_uri))
|
|
139
|
+
.global_errors(BaseApi::GLOBAL_ERRORS)
|
|
140
|
+
.user_agent(BaseApi.user_agent,
|
|
141
|
+
agent_parameters: user_agent_params)
|
|
142
|
+
|
|
143
|
+
initialize_auth_managers(@global_configuration)
|
|
144
|
+
@global_configuration = @global_configuration.auth_managers(@auth_managers)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Initializes the auth managers hash used for authenticating API calls.
|
|
148
|
+
# @param [GlobalConfiguration] global_config The global configuration of the SDK)
|
|
149
|
+
def initialize_auth_managers(global_config)
|
|
150
|
+
@auth_managers = {}
|
|
151
|
+
http_client_config = global_config.client_configuration
|
|
152
|
+
%w[basic].each { |auth| @auth_managers[auth] = nil }
|
|
153
|
+
@auth_managers['basic'] = BasicAuth.new(http_client_config.basic_auth_credentials)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Creates a client directly from environment variables.
|
|
157
|
+
def self.from_env(**overrides)
|
|
158
|
+
default_config = Configuration.build_default_config_from_env
|
|
159
|
+
new_config = default_config.clone_with(**overrides)
|
|
160
|
+
new(config: new_config)
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# walmart_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WalmartApIs
|
|
7
|
+
# An enum for SDK environments.
|
|
8
|
+
class Environment
|
|
9
|
+
ENVIRONMENT = [
|
|
10
|
+
PRODUCTION = 'production'.freeze
|
|
11
|
+
].freeze
|
|
12
|
+
|
|
13
|
+
# Converts a string or symbol into a valid Environment constant.
|
|
14
|
+
def self.from_value(value, default_value = PRODUCTION)
|
|
15
|
+
return default_value if value.nil?
|
|
16
|
+
|
|
17
|
+
default_value
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# An enum for API servers.
|
|
22
|
+
class Server
|
|
23
|
+
SERVER = [
|
|
24
|
+
SERVER_1 = 'Server 1'.freeze
|
|
25
|
+
].freeze
|
|
26
|
+
|
|
27
|
+
# Converts a string or symbol into a valid Server constant.
|
|
28
|
+
def self.from_value(value, default_value = SERVER_1)
|
|
29
|
+
return default_value if value.nil?
|
|
30
|
+
|
|
31
|
+
default_value
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# All configuration including auth info and base URI for the API access
|
|
36
|
+
# are configured in this class.
|
|
37
|
+
class Configuration < CoreLibrary::HttpClientConfiguration
|
|
38
|
+
# The attribute readers for properties.
|
|
39
|
+
attr_reader :environment, :basic_auth_credentials
|
|
40
|
+
|
|
41
|
+
class << self
|
|
42
|
+
attr_reader :environments
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def initialize(
|
|
46
|
+
connection: nil, adapter: :net_http_persistent, timeout: 30,
|
|
47
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
|
48
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
|
49
|
+
retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
|
|
50
|
+
logging_configuration: nil, environment: Environment::PRODUCTION,
|
|
51
|
+
basic_auth_credentials: nil
|
|
52
|
+
)
|
|
53
|
+
super connection: connection, adapter: adapter, timeout: timeout,
|
|
54
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
|
55
|
+
backoff_factor: backoff_factor, retry_statuses: retry_statuses,
|
|
56
|
+
retry_methods: retry_methods, http_callback: http_callback,
|
|
57
|
+
proxy_settings: proxy_settings,
|
|
58
|
+
logging_configuration: logging_configuration
|
|
59
|
+
|
|
60
|
+
# Current API environment
|
|
61
|
+
@environment = String(environment)
|
|
62
|
+
|
|
63
|
+
# The object holding Basic Authentication credentials
|
|
64
|
+
@basic_auth_credentials = basic_auth_credentials
|
|
65
|
+
|
|
66
|
+
# Initializing Basic Authentication credentials with the provided auth parameters
|
|
67
|
+
@basic_auth_credentials = basic_auth_credentials
|
|
68
|
+
|
|
69
|
+
# The Http Client to use for making requests.
|
|
70
|
+
set_http_client CoreLibrary::FaradayClient.new(self)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def clone_with(connection: nil, adapter: nil, timeout: nil,
|
|
74
|
+
max_retries: nil, retry_interval: nil, backoff_factor: nil,
|
|
75
|
+
retry_statuses: nil, retry_methods: nil, http_callback: nil,
|
|
76
|
+
proxy_settings: nil, logging_configuration: nil,
|
|
77
|
+
environment: nil, basic_auth_credentials: nil)
|
|
78
|
+
connection ||= self.connection
|
|
79
|
+
adapter ||= self.adapter
|
|
80
|
+
timeout ||= self.timeout
|
|
81
|
+
max_retries ||= self.max_retries
|
|
82
|
+
retry_interval ||= self.retry_interval
|
|
83
|
+
backoff_factor ||= self.backoff_factor
|
|
84
|
+
retry_statuses ||= self.retry_statuses
|
|
85
|
+
retry_methods ||= self.retry_methods
|
|
86
|
+
http_callback ||= self.http_callback
|
|
87
|
+
proxy_settings ||= self.proxy_settings
|
|
88
|
+
logging_configuration ||= self.logging_configuration
|
|
89
|
+
environment ||= self.environment
|
|
90
|
+
basic_auth_credentials ||= self.basic_auth_credentials
|
|
91
|
+
|
|
92
|
+
Configuration.new(connection: connection, adapter: adapter,
|
|
93
|
+
timeout: timeout, max_retries: max_retries,
|
|
94
|
+
retry_interval: retry_interval,
|
|
95
|
+
backoff_factor: backoff_factor,
|
|
96
|
+
retry_statuses: retry_statuses,
|
|
97
|
+
retry_methods: retry_methods,
|
|
98
|
+
http_callback: http_callback,
|
|
99
|
+
proxy_settings: proxy_settings,
|
|
100
|
+
logging_configuration: logging_configuration,
|
|
101
|
+
environment: environment,
|
|
102
|
+
basic_auth_credentials: basic_auth_credentials)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# All the environments the SDK can run in.
|
|
107
|
+
ENVIRONMENTS = {
|
|
108
|
+
Environment::PRODUCTION => {
|
|
109
|
+
Server::SERVER_1 => 'https://marketplace.walmartapis.com/v3'
|
|
110
|
+
}
|
|
111
|
+
}.freeze
|
|
112
|
+
|
|
113
|
+
# Generates the appropriate base URI for the environment and the server.
|
|
114
|
+
# @param [Configuration::Server] server The server enum for which the base URI is
|
|
115
|
+
# required.
|
|
116
|
+
# @return [String] The base URI.
|
|
117
|
+
def get_base_uri(server = Server::SERVER_1)
|
|
118
|
+
ENVIRONMENTS[environment][server].clone
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Builds a Configuration instance using environment variables.
|
|
122
|
+
def self.build_default_config_from_env
|
|
123
|
+
# === Core environment ===
|
|
124
|
+
environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
|
|
125
|
+
timeout = (ENV['TIMEOUT'] || 30).to_f
|
|
126
|
+
max_retries = (ENV['MAX_RETRIES'] || 0).to_i
|
|
127
|
+
retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
|
|
128
|
+
backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
|
|
129
|
+
retry_statuses = ENV.fetch('RETRY_STATUSES',
|
|
130
|
+
'[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
|
|
131
|
+
.split(',')
|
|
132
|
+
.map(&:strip)
|
|
133
|
+
.map do |item|
|
|
134
|
+
item.match?(/\A\d+\z/) ? item.to_i : item.downcase
|
|
135
|
+
end
|
|
136
|
+
retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
|
|
137
|
+
.split(',')
|
|
138
|
+
.map(&:strip)
|
|
139
|
+
.map do |item|
|
|
140
|
+
item.match?(/\A\d+\z/) ? item.to_i : item.downcase
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# === Authentication credentials ===
|
|
144
|
+
basic_auth_credentials = BasicAuthCredentials.from_env
|
|
145
|
+
|
|
146
|
+
# === Proxy settings ===
|
|
147
|
+
proxy_settings = ProxySettings.from_env
|
|
148
|
+
# === Logging Configuration ===
|
|
149
|
+
logging_configuration = LoggingConfiguration.from_env if LoggingConfiguration.any_logging_configured?
|
|
150
|
+
|
|
151
|
+
Configuration.new(
|
|
152
|
+
environment: environment,
|
|
153
|
+
timeout: timeout,
|
|
154
|
+
max_retries: max_retries,
|
|
155
|
+
retry_interval: retry_interval,
|
|
156
|
+
backoff_factor: backoff_factor,
|
|
157
|
+
retry_statuses: retry_statuses,
|
|
158
|
+
retry_methods: retry_methods,
|
|
159
|
+
basic_auth_credentials: basic_auth_credentials,
|
|
160
|
+
proxy_settings: proxy_settings,
|
|
161
|
+
logging_configuration: logging_configuration
|
|
162
|
+
)
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# walmart_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WalmartApIs
|
|
7
|
+
# Class for exceptions when there is a network error, status code error, etc.
|
|
8
|
+
class APIException < CoreLibrary::ApiException
|
|
9
|
+
# Provides a human-readable string representation of the object.
|
|
10
|
+
def to_s
|
|
11
|
+
class_name = self.class.name.split('::').last
|
|
12
|
+
"<#{class_name} status_code: #{@response_code}, reason: #{@reason}>"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
16
|
+
def inspect
|
|
17
|
+
class_name = self.class.name.split('::').last
|
|
18
|
+
"<#{class_name} status_code: #{@response_code.inspect}, reason: #{@reason.inspect}>"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# walmart_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WalmartApIs
|
|
7
|
+
# Http response received.
|
|
8
|
+
class ApiResponse < CoreLibrary::ApiResponse
|
|
9
|
+
# The constructor
|
|
10
|
+
# @param [HttpResponse] http_response The original, raw response from the api.
|
|
11
|
+
# @param [Object] data The data field specified for the response.
|
|
12
|
+
# @param [Array<String>] errors Any errors returned by the server.
|
|
13
|
+
def initialize(http_response,
|
|
14
|
+
data: nil,
|
|
15
|
+
errors: nil)
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# walmart_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WalmartApIs
|
|
7
|
+
# Utility class for basic authorization.
|
|
8
|
+
class BasicAuth < CoreLibrary::HeaderAuth
|
|
9
|
+
include CoreLibrary
|
|
10
|
+
# Display error message on occurrence of authentication failure.
|
|
11
|
+
# @returns [String] The oAuth error message.
|
|
12
|
+
def error_message
|
|
13
|
+
'BasicAuth: username or password is undefined.'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Initialization constructor.
|
|
17
|
+
def initialize(basic_auth_credentials)
|
|
18
|
+
auth_params = {}
|
|
19
|
+
unless basic_auth_credentials.nil? ||
|
|
20
|
+
basic_auth_credentials.username.nil? ||
|
|
21
|
+
basic_auth_credentials.password.nil?
|
|
22
|
+
auth_params['Authorization'] =
|
|
23
|
+
"Basic #{AuthHelper.get_base64_encoded_value(basic_auth_credentials.username,
|
|
24
|
+
basic_auth_credentials.password)}"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
super auth_params
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Data class for BasicAuthCredentials.
|
|
32
|
+
class BasicAuthCredentials
|
|
33
|
+
attr_reader :username, :password
|
|
34
|
+
|
|
35
|
+
def initialize(username:, password:)
|
|
36
|
+
raise ArgumentError, 'username cannot be nil' if username.nil?
|
|
37
|
+
raise ArgumentError, 'password cannot be nil' if password.nil?
|
|
38
|
+
|
|
39
|
+
@username = username
|
|
40
|
+
@password = password
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.from_env
|
|
44
|
+
username = ENV['USERNAME']
|
|
45
|
+
password = ENV['PASSWORD']
|
|
46
|
+
all_nil = [
|
|
47
|
+
username,
|
|
48
|
+
password
|
|
49
|
+
].all?(&:nil?)
|
|
50
|
+
return nil if all_nil
|
|
51
|
+
|
|
52
|
+
new(username: username, password: password)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def clone_with(username: nil, password: nil)
|
|
56
|
+
username ||= self.username
|
|
57
|
+
password ||= self.password
|
|
58
|
+
|
|
59
|
+
BasicAuthCredentials.new(username: username, password: password)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# walmart_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WalmartApIs
|
|
7
|
+
# HttpCallBack allows defining callables for pre and post API calls.
|
|
8
|
+
class HttpCallBack < CoreLibrary::HttpCallback
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# walmart_ap_is
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module WalmartApIs
|
|
7
|
+
##
|
|
8
|
+
# ProxySettings encapsulates HTTP proxy configuration for Faraday,
|
|
9
|
+
# including optional basic authentication.
|
|
10
|
+
#
|
|
11
|
+
class ProxySettings < CoreLibrary::ProxySettings
|
|
12
|
+
def self.from_env
|
|
13
|
+
address = ENV['PROXY_ADDRESS']
|
|
14
|
+
port = ENV['PROXY_PORT']
|
|
15
|
+
username = ENV['PROXY_USERNAME']
|
|
16
|
+
password = ENV['PROXY_PASSWORD']
|
|
17
|
+
return nil if address.nil? || address.strip.empty?
|
|
18
|
+
|
|
19
|
+
new(address: address, port: port, username: username, password: password)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|