amazon-ads 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +49 -16
  3. data/lib/amazon_ads/api.rb +47 -97
  4. data/lib/amazon_ads/apis/ad_associations.rb +30 -0
  5. data/lib/amazon_ads/apis/ad_extensions.rb +24 -0
  6. data/lib/amazon_ads/apis/ad_groups.rb +30 -0
  7. data/lib/amazon_ads/apis/ads.rb +30 -0
  8. data/lib/amazon_ads/apis/advertising_deal_targets.rb +24 -0
  9. data/lib/amazon_ads/apis/advertising_deals.rb +30 -0
  10. data/lib/amazon_ads/apis/brand_store_edition_publish_versions.rb +18 -0
  11. data/lib/amazon_ads/apis/brand_store_editions.rb +12 -0
  12. data/lib/amazon_ads/apis/brand_store_pages.rb +12 -0
  13. data/lib/amazon_ads/apis/brand_stores.rb +12 -0
  14. data/lib/amazon_ads/apis/branded_keywords_pricings.rb +12 -0
  15. data/lib/amazon_ads/apis/campaign_forecasts.rb +12 -0
  16. data/lib/amazon_ads/apis/campaigns.rb +30 -0
  17. data/lib/amazon_ads/apis/commitment_spends.rb +12 -0
  18. data/lib/amazon_ads/apis/commitments.rb +30 -0
  19. data/lib/amazon_ads/apis/keyword_reservation_validations.rb +12 -0
  20. data/lib/amazon_ads/apis/marketing_stream.rb +73 -0
  21. data/lib/amazon_ads/apis/profiles.rb +15 -14
  22. data/lib/amazon_ads/apis/recommendation_types.rb +12 -0
  23. data/lib/amazon_ads/apis/recommendations.rb +12 -0
  24. data/lib/amazon_ads/apis/reporting.rb +30 -0
  25. data/lib/amazon_ads/apis/targets.rb +30 -0
  26. data/lib/amazon_ads/lwa.rb +36 -57
  27. data/lib/amazon_ads/version.rb +1 -1
  28. data/lib/amazon_ads.rb +28 -15
  29. data/sig/generated/amazon_ads/api.rbs +20 -38
  30. data/sig/generated/amazon_ads/apis/ad_associations.rbs +21 -0
  31. data/sig/generated/amazon_ads/apis/ad_extensions.rbs +17 -0
  32. data/sig/generated/amazon_ads/apis/ad_groups.rbs +21 -0
  33. data/sig/generated/amazon_ads/apis/ads.rbs +21 -0
  34. data/sig/generated/amazon_ads/apis/advertising_deal_targets.rbs +17 -0
  35. data/sig/generated/amazon_ads/apis/advertising_deals.rbs +21 -0
  36. data/sig/generated/amazon_ads/apis/brand_store_edition_publish_versions.rbs +13 -0
  37. data/sig/generated/amazon_ads/apis/brand_store_editions.rbs +9 -0
  38. data/sig/generated/amazon_ads/apis/brand_store_pages.rbs +9 -0
  39. data/sig/generated/amazon_ads/apis/brand_stores.rbs +9 -0
  40. data/sig/generated/amazon_ads/apis/branded_keywords_pricings.rbs +9 -0
  41. data/sig/generated/amazon_ads/apis/campaign_forecasts.rbs +9 -0
  42. data/sig/generated/amazon_ads/apis/campaigns.rbs +21 -0
  43. data/sig/generated/amazon_ads/apis/commitment_spends.rbs +9 -0
  44. data/sig/generated/amazon_ads/apis/commitments.rbs +21 -0
  45. data/sig/generated/amazon_ads/apis/keyword_reservation_validations.rbs +9 -0
  46. data/sig/generated/amazon_ads/apis/marketing_stream.rbs +56 -0
  47. data/sig/generated/amazon_ads/apis/profiles.rbs +12 -10
  48. data/sig/generated/amazon_ads/apis/recommendation_types.rbs +9 -0
  49. data/sig/generated/amazon_ads/apis/recommendations.rbs +9 -0
  50. data/sig/generated/amazon_ads/apis/reporting.rbs +23 -0
  51. data/sig/generated/amazon_ads/apis/streams.rbs +40 -0
  52. data/sig/generated/amazon_ads/apis/targets.rbs +21 -0
  53. data/sig/generated/amazon_ads/lwa.rbs +21 -23
  54. data/sig/generated/amazon_ads.rbs +23 -9
  55. metadata +59 -9
  56. data/lib/amazon_ads/apis/sponsored_products.rb +0 -76
  57. data/lib/amazon_ads/client.rb +0 -38
  58. data/lib/amazon_ads/configuration.rb +0 -34
  59. data/lib/amazon_ads/errors.rb +0 -43
  60. data/sig/generated/amazon_ads/client.rbs +0 -28
  61. data/sig/generated/amazon_ads/configuration.rbs +0 -24
  62. data/sig/generated/amazon_ads/errors.rbs +0 -35
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ module AmazonAds
5
+ # Amazon Marketing Stream
6
+ class MarketingStream < API
7
+ # Create a new subscription Note: trailing slash in request uri is not allowed
8
+ # @rbs client_request_token: String -- Unique value supplied by the caller used to track identical API requests. Should request be re-tried, the caller should supply the same value. We recommend using GUID.
9
+ # @rbs data_set_id: String -- Identifier of data set, callers can be subscribed to. Please refer to https://advertising.amazon.com/API/docs/en-us/amazon-marketing-stream/data-guide for the list of all data sets.
10
+ # @rbs destination_arn: String -- AWS ARN of the destination endpoint associated with the subscription. Supported destination types: - SQS
11
+ # @rbs notes: String -- Additional details associated with the subscription
12
+ #: (client_request_token: String, data_set_id: String, ?destination: String?, ?destination_arn: String?, ?notes: String?) -> HTTP::Response
13
+ def create_dsp_stream_subscription(client_request_token:, data_set_id:, destination: nil, destination_arn: nil, notes: nil)
14
+ request(:post, "/dsp/streams/subscriptions", json: { "clientRequestToken" => client_request_token, "dataSetId" => data_set_id, "destination" => destination, "destinationArn" => destination_arn, "notes" => notes }.compact, headers: { "Content-Type" => "application/vnd.amazonmarketingstreamsubscriptions.v1+json" })
15
+ end
16
+
17
+ # Create a new subscription Note: trailing slash in request uri is not allowed
18
+ # @rbs client_request_token: String -- Unique value supplied by the caller used to track identical API requests. Should request be re-tried, the caller should supply the same value. We recommend using GUID.
19
+ # @rbs data_set_id: String -- Identifier of data set, callers can be subscribed to. Please refer to https://advertising.amazon.com/API/docs/en-us/amazon-marketing-stream/data-guide for the list of all data sets.
20
+ # @rbs destination_arn: String -- AWS ARN of the destination endpoint associated with the subscription. Supported destination types: - SQS
21
+ # @rbs notes: String -- Additional details associated with the subscription
22
+ #: (client_request_token: String, data_set_id: String, ?destination: String?, ?destination_arn: String?, ?notes: String?) -> HTTP::Response
23
+ def create_stream_subscription(client_request_token:, data_set_id:, destination: nil, destination_arn: nil, notes: nil)
24
+ request(:post, "/streams/subscriptions", json: { "clientRequestToken" => client_request_token, "dataSetId" => data_set_id, "destination" => destination, "destinationArn" => destination_arn, "notes" => notes }.compact, headers: { "Content-Type" => "application/vnd.amazonmarketingstreamsubscriptions.v1+json" })
25
+ end
26
+
27
+ # Fetch a specific subscription by Id Note: trailing slash in request uri is not allowed
28
+ # @rbs subscription_id: String -- Unique subscription identifier
29
+ #: (String) -> HTTP::Response
30
+ def get_dsp_stream_subscription(subscription_id)
31
+ request(:get, "/dsp/streams/subscriptions/#{subscription_id}")
32
+ end
33
+
34
+ # Fetch a specific subscription by Id Note: trailing slash in request uri is not allowed
35
+ # @rbs subscription_id: String -- Unique subscription identifier
36
+ #: (String) -> HTTP::Response
37
+ def get_stream_subscription(subscription_id)
38
+ request(:get, "/streams/subscriptions/#{subscription_id}")
39
+ end
40
+
41
+ # List subscriptions Note: trailing slash in request uri is not allowed
42
+ # @rbs max_results: Numeric -- desired number of entries in the response, defaults to maximum value
43
+ # @rbs starting_token: String -- Token which can be used to get the next page of results, if more entries exist
44
+ #: (?max_results: Numeric?, ?starting_token: String?) -> HTTP::Response
45
+ def list_dsp_stream_subscriptions(max_results: nil, starting_token: nil)
46
+ request(:get, "/dsp/streams/subscriptions", params: { "maxResults" => max_results, "startingToken" => starting_token }.compact)
47
+ end
48
+
49
+ # List subscriptions Note: trailing slash in request uri is not allowed
50
+ # @rbs max_results: Numeric -- desired number of entries in the response, defaults to maximum value
51
+ # @rbs starting_token: String -- Token which can be used to get the next page of results, if more entries exist
52
+ #: (?max_results: Numeric?, ?starting_token: String?) -> HTTP::Response
53
+ def list_stream_subscriptions(max_results: nil, starting_token: nil)
54
+ request(:get, "/streams/subscriptions", params: { "maxResults" => max_results, "startingToken" => starting_token }.compact)
55
+ end
56
+
57
+ # Update an existing subscription Note: trailing slash in request uri is not allowed
58
+ # @rbs subscription_id: String -- Unique subscription identifier
59
+ # @rbs notes: String -- Additional details associated with the subscription
60
+ #: (String, ?notes: String?, ?status: String?) -> HTTP::Response
61
+ def update_dsp_stream_subscription(subscription_id, notes: nil, status: nil)
62
+ request(:put, "/dsp/streams/subscriptions/#{subscription_id}", json: { "notes" => notes, "status" => status }.compact, headers: { "Content-Type" => "application/vnd.amazonmarketingstreamsubscriptions.v1+json" })
63
+ end
64
+
65
+ # Update an existing subscription Note: trailing slash in request uri is not allowed
66
+ # @rbs subscription_id: String -- Unique subscription identifier
67
+ # @rbs notes: String -- Additional details associated with the subscription
68
+ #: (String, ?notes: String?, ?status: String?) -> HTTP::Response
69
+ def update_stream_subscription(subscription_id, notes: nil, status: nil)
70
+ request(:put, "/streams/subscriptions/#{subscription_id}", json: { "notes" => notes, "status" => status }.compact, headers: { "Content-Type" => "application/vnd.amazonmarketingstreamsubscriptions.v1+json" })
71
+ end
72
+ end
73
+ end
@@ -1,28 +1,29 @@
1
1
  # frozen_string_literal: true
2
-
3
2
  # rbs_inline: enabled
4
3
 
5
4
  module AmazonAds
6
5
  # Amazon Ads API - Profiles
7
- #
8
- # @see https://advertising.amazon.com/API/docs/en-us/reference/profiles
9
6
  class Profiles < API
7
+ # Gets a profile specified by identifier.
8
+ #: (Integer) -> HTTP::Response
9
+ def get_profile_by_id(profile_id)
10
+ request(:get, "/v2/profiles/#{profile_id}")
11
+ end
12
+
10
13
  # Gets a list of profiles.
11
- #: (?api_program: String?, ?access_level: String?, ?profile_type_filter: String?, ?valid_payment_method_filter: String?) -> untyped
14
+ # @rbs api_program: String -- Filters response to include profiles that have permissions for the specified Advertising API program only. Setting `apiProgram=billing` filters the response to include only profiles to which the user and application associated with the access token have permission to view or edit billing information.
15
+ # @rbs access_level: String -- Filters response to include profiles that have specified permissions for the specified Advertising API program only. Currently, the only supported access level is `view` and `edit`. Setting `accessLevel=view` filters the response to include only profiles to which the user and application associated with the access token have view permission to the provided api program.
16
+ # @rbs profile_type_filter: String -- Filters response to include profiles that are of the specified types in the comma-delimited list. Default is all types. Note that this filter performs an inclusive AND operation on the types.
17
+ # @rbs valid_payment_method_filter: String -- Filter response to include profiles that have valid payment methods. Default is to include all profiles. Setting this filter to `true` returns only profiles with either no `validPaymentMethod` field, or the `validPaymentMethod` field set to `true`. Setting this to `false` returns profiles with the `validPaymentMethod` field set to `false` only.
18
+ #: (?api_program: String?, ?access_level: String?, ?profile_type_filter: String?, ?valid_payment_method_filter: String?) -> HTTP::Response
12
19
  def list_profiles(api_program: nil, access_level: nil, profile_type_filter: nil, valid_payment_method_filter: nil)
13
- get("/v2/profiles", params: { "apiProgram" => api_program, "accessLevel" => access_level, "profileTypeFilter" => profile_type_filter, "validPaymentMethodFilter" => valid_payment_method_filter }.compact)
20
+ request(:get, "/v2/profiles", params: { "apiProgram" => api_program, "accessLevel" => access_level, "profileTypeFilter" => profile_type_filter, "validPaymentMethodFilter" => valid_payment_method_filter }.compact)
14
21
  end
15
22
 
16
23
  # Update the daily budget for one or more profiles.
17
- #: (?body: Hash[String, untyped]) -> untyped
18
- def update_profiles(body: {})
19
- put("/v2/profiles", body: body)
20
- end
21
-
22
- # Gets a profile specified by identifier.
23
- #: (Integer) -> untyped
24
- def get_profile_by_id(profile_id)
25
- get("/v2/profiles/#{profile_id}")
24
+ #: (?json: untyped) -> HTTP::Response
25
+ def update_profiles(json: {})
26
+ request(:put, "/v2/profiles", json: json)
26
27
  end
27
28
  end
28
29
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ module AmazonAds
5
+ class RecommendationTypes < API
6
+ # Query RecommendationTypes
7
+ #: (?max_results: Integer?, ?next_token: String?) -> HTTP::Response
8
+ def sb_query_recommendation_type(max_results: nil, next_token: nil)
9
+ request(:post, "/adsApi/v1/query/recommendationTypes/sb", json: { "maxResults" => max_results, "nextToken" => next_token }.compact)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ module AmazonAds
5
+ class Recommendations < API
6
+ # Create recommendations
7
+ #: (?recommendations: Array[untyped]?) -> HTTP::Response
8
+ def sb_create_recommendation(recommendations: nil)
9
+ request(:post, "/adsApi/v1/create/recommendations/sb", json: { "recommendations" => recommendations }.compact)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ module AmazonAds
5
+ # Offline Report
6
+ class Reporting < API
7
+ # Creates a report request
8
+ # @rbs end_date: String -- YYYY-MM-DD format. The maximum lookback window supported depends on the selection of reportTypeId. Most report types support `95 days` as lookback window.
9
+ # @rbs name: String -- The name of the report.
10
+ # @rbs start_date: String -- YYYY-MM-DD format. The maximum lookback window supported depends on the selection of reportTypeId. Most report types support `95 days` as lookback window.
11
+ #: (configuration: untyped, end_date: String, start_date: String, ?name: String?) -> HTTP::Response
12
+ def create_async_report(configuration:, end_date:, start_date:, name: nil)
13
+ request(:post, "/reporting/reports", json: { "configuration" => configuration, "endDate" => end_date, "name" => name, "startDate" => start_date }.compact, headers: { "Content-Type" => "application/vnd.createasyncreportrequest.v3+json" })
14
+ end
15
+
16
+ # Deletes a report by id
17
+ # @rbs report_id: String -- The identifier of the requested report.
18
+ #: (String) -> HTTP::Response
19
+ def delete_async_report(report_id)
20
+ request(:delete, "/reporting/reports/#{report_id}")
21
+ end
22
+
23
+ # Gets a generation status of report by id
24
+ # @rbs report_id: String -- The identifier of the requested report.
25
+ #: (String) -> HTTP::Response
26
+ def get_async_report(report_id)
27
+ request(:get, "/reporting/reports/#{report_id}")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ # rbs_inline: enabled
3
+
4
+ module AmazonAds
5
+ class Targets < API
6
+ # Create target
7
+ #: (?targets: Array[untyped]?) -> HTTP::Response
8
+ def create_target(targets: nil)
9
+ request(:post, "/adsApi/v1/create/targets", json: { "targets" => targets }.compact)
10
+ end
11
+
12
+ # Delete target
13
+ #: (?target_ids: Array[untyped]?) -> HTTP::Response
14
+ def delete_target(target_ids: nil)
15
+ request(:post, "/adsApi/v1/delete/targets", json: { "targetIds" => target_ids }.compact)
16
+ end
17
+
18
+ # List target
19
+ #: (ad_product_filter: String, ?ad_group_id_filter: String?, ?campaign_id_filter: String?, ?keyword_filter: String?, ?marketplace_scope_filter: String?, ?match_type_filter: String?, ?max_results: Integer?, ?native_language_locale_filter: String?, ?negative_filter: String?, ?next_token: String?, ?product_id_filter: String?, ?state_filter: String?, ?target_id_filter: String?, ?target_type_filter: String?) -> HTTP::Response
20
+ def query_target(ad_product_filter:, ad_group_id_filter: nil, campaign_id_filter: nil, keyword_filter: nil, marketplace_scope_filter: nil, match_type_filter: nil, max_results: nil, native_language_locale_filter: nil, negative_filter: nil, next_token: nil, product_id_filter: nil, state_filter: nil, target_id_filter: nil, target_type_filter: nil)
21
+ request(:post, "/adsApi/v1/query/targets", json: { "adGroupIdFilter" => ad_group_id_filter, "adProductFilter" => ad_product_filter, "campaignIdFilter" => campaign_id_filter, "keywordFilter" => keyword_filter, "marketplaceScopeFilter" => marketplace_scope_filter, "matchTypeFilter" => match_type_filter, "maxResults" => max_results, "nativeLanguageLocaleFilter" => native_language_locale_filter, "negativeFilter" => negative_filter, "nextToken" => next_token, "productIdFilter" => product_id_filter, "stateFilter" => state_filter, "targetIdFilter" => target_id_filter, "targetTypeFilter" => target_type_filter }.compact)
22
+ end
23
+
24
+ # Update target
25
+ #: (?targets: Array[untyped]?) -> HTTP::Response
26
+ def update_target(targets: nil)
27
+ request(:post, "/adsApi/v1/update/targets", json: { "targets" => targets }.compact)
28
+ end
29
+ end
30
+ end
@@ -5,80 +5,59 @@
5
5
  require "http"
6
6
 
7
7
  module AmazonAds
8
- # Requests Login with Amazon (LWA) access tokens for the Amazon Ads API.
9
- # Handles token caching and automatic refresh when tokens expire.
10
- #
11
- # @see https://advertising.amazon.com/API/docs/en-us/info/api-overview
8
+ # Requests Login with Amazon (LWA) access tokens for the Amazon Ads API
9
+ # Stateless: each call to #request hits the token endpoint; the caller
10
+ # owns caching
12
11
  class LWA
13
12
  URL = "https://api.amazon.com/auth/o2/token" #: String
14
- TOKEN_EXPIRY_BUFFER = 60 #: Integer
15
13
 
16
- attr_reader :client_id #: String
17
- attr_reader :client_secret #: String
14
+ # The OAuth refresh token
18
15
  attr_reader :refresh_token #: String
19
16
 
20
- #: (?client_id: String, ?client_secret: String, ?refresh_token: String) -> void
21
- def initialize(
22
- client_id: ENV.fetch("AMAZON_ADS_CLIENT_ID"),
23
- client_secret: ENV.fetch("AMAZON_ADS_CLIENT_SECRET"),
24
- refresh_token: ENV.fetch("AMAZON_ADS_REFRESH_TOKEN")
25
- )
26
- @client_id = client_id
27
- @client_secret = client_secret
28
- @refresh_token = refresh_token
29
- @access_token = nil #: String?
30
- @expires_at = nil #: Time?
31
- @mutex = Mutex.new
32
- end
33
-
34
- # Returns a valid access token, refreshing if necessary.
35
- #: () -> String
36
- def access_token
37
- @mutex.synchronize do
38
- refresh! if token_expired?
39
- @access_token or raise AmazonAds::AuthenticationError, "Failed to obtain access token"
17
+ class << self
18
+ #: (**untyped) -> Hash[String, untyped]
19
+ def request(...)
20
+ new(...).request
40
21
  end
41
22
  end
42
23
 
43
- # Forces a token refresh regardless of expiry.
44
- #: () -> String
45
- def refresh!
46
- response = HTTP.post(URL, form: params)
47
-
48
- unless response.status.success?
49
- body = begin
50
- response.parse
51
- rescue StandardError
52
- {}
53
- end
54
- message = body["error_description"] || body["error"] || "Authentication failed"
55
- raise AmazonAds::AuthenticationError.new(message, response: response)
56
- end
57
-
58
- data = response.parse
59
- @access_token = data.fetch("access_token")
60
- expires_in = data.fetch("expires_in", 3600)
61
- @expires_at = Time.now + expires_in - TOKEN_EXPIRY_BUFFER
62
-
63
- @access_token
24
+ #: (refresh_token: String, ?http: untyped) -> void
25
+ def initialize(refresh_token:, http: HTTP)
26
+ @refresh_token = refresh_token
27
+ @http = http
64
28
  end
65
29
 
66
- # Returns true if the token is expired or not yet fetched.
67
- #: () -> bool
68
- def token_expired?
69
- @access_token.nil? || @expires_at.nil? || Time.now >= @expires_at
30
+ # Requests a fresh access token from LWA
31
+ #: () -> Hash[String, untyped]
32
+ def request
33
+ http.post(URL, form: params).parse
70
34
  end
71
35
 
72
36
  private
73
37
 
74
- #: () -> Hash[String, String]
38
+ #: () -> HTTP::Client
39
+ def http
40
+ @http.use(:raise_error)
41
+ end
42
+
43
+ #: () -> Hash[Symbol, String]
75
44
  def params
76
45
  {
77
- "grant_type" => "refresh_token",
78
- "client_id" => client_id,
79
- "client_secret" => client_secret,
80
- "refresh_token" => refresh_token,
46
+ grant_type: "refresh_token",
47
+ client_id:,
48
+ client_secret:,
49
+ refresh_token:,
81
50
  }
82
51
  end
52
+
53
+ #: () -> String
54
+ def client_id
55
+ AmazonAds.client_id!
56
+ end
57
+
58
+ #: () -> String
59
+ def client_secret
60
+ AmazonAds.client_secret!
61
+ end
83
62
  end
84
63
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AmazonAds
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/amazon_ads.rb CHANGED
@@ -8,30 +8,43 @@ loader = Zeitwerk::Loader.for_gem
8
8
  loader.inflector.inflect("api" => "API", "lwa" => "LWA")
9
9
  loader.collapse("#{__dir__}/amazon_ads/apis")
10
10
  loader.ignore("#{__dir__}/generator")
11
- loader.ignore("#{__dir__}/amazon_ads/errors.rb")
12
11
  loader.setup
13
12
 
14
- require_relative "amazon_ads/errors"
15
-
16
13
  # Amazon Ads API client for Ruby
17
14
  module AmazonAds
18
15
  class << self
19
- # Returns the global configuration object.
20
- #: () -> Configuration
21
- def configuration
22
- @configuration ||= Configuration.new
16
+ # Returns the client ID
17
+ # Falls back to the `AMAZON_ADS_CLIENT_ID` env var
18
+ #: () -> String?
19
+ def client_id
20
+ @client_id || ENV["AMAZON_ADS_CLIENT_ID"]
23
21
  end
24
22
 
25
- # Configures the AmazonAds library.
26
- #: () { (Configuration) -> void } -> void
27
- def configure
28
- yield(configuration)
23
+ # Sets the client ID
24
+ #: (String?) -> String?
25
+ attr_writer :client_id
26
+
27
+ # Returns the client ID or raises
28
+ #: () -> String
29
+ def client_id!
30
+ client_id or raise ArgumentError, "client id is required"
29
31
  end
30
32
 
31
- # Resets the configuration to defaults.
32
- #: () -> void
33
- def reset_configuration!
34
- @configuration = Configuration.new
33
+ # Returns the client secret
34
+ # Falls back to the `AMAZON_ADS_CLIENT_SECRET` env var
35
+ #: () -> String?
36
+ def client_secret
37
+ @client_secret || ENV["AMAZON_ADS_CLIENT_SECRET"]
38
+ end
39
+
40
+ # Sets the client secret
41
+ #: (String?) -> String?
42
+ attr_writer :client_secret
43
+
44
+ # Returns the client secret or raises
45
+ #: () -> String
46
+ def client_secret!
47
+ client_secret or raise ArgumentError, "client secret is required"
35
48
  end
36
49
  end
37
50
  end
@@ -1,61 +1,43 @@
1
1
  # Generated from lib/amazon_ads/api.rb with RBS::Inline
2
2
 
3
3
  module AmazonAds
4
- # Base class for Amazon Ads API clients.
5
- # Handles authentication, response parsing, error mapping, and retry logic.
4
+ # Base class for Amazon Ads API endpoints
6
5
  class API
7
6
  ENDPOINTS: untyped
8
7
 
9
- MAX_RETRIES: Integer
10
-
11
- BASE_RETRY_DELAY: Integer
12
-
8
+ # API endpoint region
13
9
  attr_reader region: Symbol
14
10
 
11
+ # LWA access token
12
+ attr_reader access_token: String
13
+
14
+ # Advertiser profile, scopes requests to a marketplace
15
15
  attr_reader profile_id: String?
16
16
 
17
- # : (region: Symbol, ?access_token: String?, ?lwa: LWA?, ?profile_id: String?) -> void
18
- def initialize: (region: Symbol, ?access_token: String?, ?lwa: LWA?, ?profile_id: String?) -> void
17
+ # Advertiser account
18
+ attr_reader account_id: String?
19
19
 
20
- private
20
+ # Number of retries when throttled (default: 0)
21
+ attr_reader retries: Integer
21
22
 
22
- # Returns the current access token, refreshing via LWA if needed.
23
- # : () -> String
24
- def access_token: () -> String
23
+ # : (region: Symbol | String, access_token: String, ?profile_id: String?, ?account_id: String?, ?retries: Integer, ?http: untyped) -> void
24
+ def initialize: (region: Symbol | String, access_token: String, ?profile_id: String?, ?account_id: String?, ?retries: Integer, ?http: untyped) -> void
25
+
26
+ # : () -> URI::HTTPS
27
+ def endpoint: () -> URI::HTTPS
25
28
 
26
29
  # : () -> HTTP::Client
27
30
  def http: () -> HTTP::Client
28
31
 
32
+ private
33
+
34
+ # : (Symbol, String, **untyped) -> HTTP::Response
35
+ def request: (Symbol, String, **untyped) -> HTTP::Response
36
+
29
37
  # : () -> Hash[String, String]
30
38
  def default_headers: () -> Hash[String, String]
31
39
 
32
40
  # : () -> String
33
41
  def client_id: () -> String
34
-
35
- # : () -> String
36
- def endpoint: () -> String
37
-
38
- # Handles HTTP response, raising appropriate errors or parsing success responses.
39
- # : (HTTP::Response) -> untyped
40
- def handle_response: (HTTP::Response) -> untyped
41
-
42
- # Executes request with retry logic for rate limiting.
43
- # : () { () -> HTTP::Response } -> untyped
44
- def with_retry: () { () -> HTTP::Response } -> untyped
45
-
46
- # : (String, ?params: Hash[String, untyped]) -> untyped
47
- def get: (String, ?params: Hash[String, untyped]) -> untyped
48
-
49
- # : (String, ?body: Hash[String, untyped]) -> untyped
50
- def post: (String, ?body: Hash[String, untyped]) -> untyped
51
-
52
- # : (String, ?body: Hash[String, untyped]) -> untyped
53
- def put: (String, ?body: Hash[String, untyped]) -> untyped
54
-
55
- # : (String, ?body: Hash[String, untyped]) -> untyped
56
- def patch: (String, ?body: Hash[String, untyped]) -> untyped
57
-
58
- # : (String) -> untyped
59
- def delete: (String) -> untyped
60
42
  end
61
43
  end
@@ -0,0 +1,21 @@
1
+ # Generated from lib/amazon_ads/apis/ad_associations.rb with RBS::Inline
2
+
3
+ module AmazonAds
4
+ class AdAssociations < API
5
+ # Create Ad Association
6
+ # : (?ad_associations: Array[untyped]?) -> HTTP::Response
7
+ def create_ad_association: (?ad_associations: Array[untyped]?) -> HTTP::Response
8
+
9
+ # Delete Ad Association
10
+ # : (?ad_association_ids: Array[untyped]?) -> HTTP::Response
11
+ def delete_ad_association: (?ad_association_ids: Array[untyped]?) -> HTTP::Response
12
+
13
+ # Query Ad Association
14
+ # : (?ad_association_id_filter: String?, ?ad_group_id_filter: String?, ?ad_id_filter: String?, ?max_results: Integer?, ?next_token: String?) -> HTTP::Response
15
+ def query_ad_association: (?ad_association_id_filter: String?, ?ad_group_id_filter: String?, ?ad_id_filter: String?, ?max_results: Integer?, ?next_token: String?) -> HTTP::Response
16
+
17
+ # Update Ad Association
18
+ # : (?ad_associations: Array[untyped]?) -> HTTP::Response
19
+ def update_ad_association: (?ad_associations: Array[untyped]?) -> HTTP::Response
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ # Generated from lib/amazon_ads/apis/ad_extensions.rb with RBS::Inline
2
+
3
+ module AmazonAds
4
+ class AdExtensions < API
5
+ # Create ad extensions - API is in open beta
6
+ # : (?ad_extensions: Array[untyped]?) -> HTTP::Response
7
+ def create_ad_extension: (?ad_extensions: Array[untyped]?) -> HTTP::Response
8
+
9
+ # Query ad_extension - API is in open beta
10
+ # : (?ad_extension_id_filter: String?, ?ad_extension_status_filter: String?, ?ad_extension_type_filter: String?, ?ad_group_id_filter: String?, ?ad_id_filter: String?, ?ad_product_filter: String?, ?max_results: Integer?, ?next_token: String?, ?state_filter: String?) -> HTTP::Response
11
+ def query_ad_extension: (?ad_extension_id_filter: String?, ?ad_extension_status_filter: String?, ?ad_extension_type_filter: String?, ?ad_group_id_filter: String?, ?ad_id_filter: String?, ?ad_product_filter: String?, ?max_results: Integer?, ?next_token: String?, ?state_filter: String?) -> HTTP::Response
12
+
13
+ # Update ad_extension - API is in open beta
14
+ # : (?ad_extensions: Array[untyped]?) -> HTTP::Response
15
+ def update_ad_extension: (?ad_extensions: Array[untyped]?) -> HTTP::Response
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ # Generated from lib/amazon_ads/apis/ad_groups.rb with RBS::Inline
2
+
3
+ module AmazonAds
4
+ class AdGroups < API
5
+ # Create ad groups
6
+ # : (?ad_groups: Array[untyped]?) -> HTTP::Response
7
+ def create_ad_group: (?ad_groups: Array[untyped]?) -> HTTP::Response
8
+
9
+ # Delete ad groups
10
+ # : (?ad_group_ids: Array[untyped]?) -> HTTP::Response
11
+ def delete_ad_group: (?ad_group_ids: Array[untyped]?) -> HTTP::Response
12
+
13
+ # List ad groups
14
+ # : (ad_product_filter: String, ?ad_group_id_filter: String?, ?campaign_id_filter: String?, ?marketplace_scope_filter: String?, ?max_results: Integer?, ?name_filter: String?, ?next_token: String?, ?state_filter: String?) -> HTTP::Response
15
+ def query_ad_group: (ad_product_filter: String, ?ad_group_id_filter: String?, ?campaign_id_filter: String?, ?marketplace_scope_filter: String?, ?max_results: Integer?, ?name_filter: String?, ?next_token: String?, ?state_filter: String?) -> HTTP::Response
16
+
17
+ # Update ad groups
18
+ # : (?ad_groups: Array[untyped]?) -> HTTP::Response
19
+ def update_ad_group: (?ad_groups: Array[untyped]?) -> HTTP::Response
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # Generated from lib/amazon_ads/apis/ads.rb with RBS::Inline
2
+
3
+ module AmazonAds
4
+ class Ads < API
5
+ # Create ads
6
+ # : (?ads: Array[untyped]?) -> HTTP::Response
7
+ def create_ad: (?ads: Array[untyped]?) -> HTTP::Response
8
+
9
+ # Delete ads
10
+ # : (?ad_ids: Array[untyped]?) -> HTTP::Response
11
+ def delete_ad: (?ad_ids: Array[untyped]?) -> HTTP::Response
12
+
13
+ # List ads
14
+ # : (ad_product_filter: String, ?ad_group_id_filter: String?, ?ad_id_filter: String?, ?campaign_id_filter: String?, ?marketplace_scope_filter: String?, ?max_results: Integer?, ?name_filter: String?, ?next_token: String?, ?state_filter: String?) -> HTTP::Response
15
+ def query_ad: (ad_product_filter: String, ?ad_group_id_filter: String?, ?ad_id_filter: String?, ?campaign_id_filter: String?, ?marketplace_scope_filter: String?, ?max_results: Integer?, ?name_filter: String?, ?next_token: String?, ?state_filter: String?) -> HTTP::Response
16
+
17
+ # Update ads
18
+ # : (?ads: Array[untyped]?) -> HTTP::Response
19
+ def update_ad: (?ads: Array[untyped]?) -> HTTP::Response
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ # Generated from lib/amazon_ads/apis/advertising_deal_targets.rb with RBS::Inline
2
+
3
+ module AmazonAds
4
+ class AdvertisingDealTargets < API
5
+ # Create advertisingDealTarget
6
+ # : (?advertising_deal_targets: Array[untyped]?) -> HTTP::Response
7
+ def sb_create_advertising_deal_target: (?advertising_deal_targets: Array[untyped]?) -> HTTP::Response
8
+
9
+ # Delete advertisingDealTarget
10
+ # : (?advertising_deal_target_ids: Array[untyped]?) -> HTTP::Response
11
+ def sb_delete_advertising_deal_target: (?advertising_deal_target_ids: Array[untyped]?) -> HTTP::Response
12
+
13
+ # Query advertisingDealTarget
14
+ # : (advertising_deal_id_filter: String, ?max_results: Integer?, ?next_token: String?) -> HTTP::Response
15
+ def sb_query_advertising_deal_target: (advertising_deal_id_filter: String, ?max_results: Integer?, ?next_token: String?) -> HTTP::Response
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ # Generated from lib/amazon_ads/apis/advertising_deals.rb with RBS::Inline
2
+
3
+ module AmazonAds
4
+ class AdvertisingDeals < API
5
+ # Create advertisingDeal
6
+ # : (?advertising_deals: Array[untyped]?) -> HTTP::Response
7
+ def sb_create_advertising_deal: (?advertising_deals: Array[untyped]?) -> HTTP::Response
8
+
9
+ # Delete advertisingDeal
10
+ # : (?advertising_deal_ids: Array[untyped]?) -> HTTP::Response
11
+ def sb_delete_advertising_deal: (?advertising_deal_ids: Array[untyped]?) -> HTTP::Response
12
+
13
+ # Query advertisingDeal
14
+ # : (?advertising_deal_id_filter: String?, ?max_results: Integer?, ?name_filter: String?, ?next_token: String?) -> HTTP::Response
15
+ def sb_query_advertising_deal: (?advertising_deal_id_filter: String?, ?max_results: Integer?, ?name_filter: String?, ?next_token: String?) -> HTTP::Response
16
+
17
+ # Update advertisingDeal
18
+ # : (?advertising_deals: Array[untyped]?) -> HTTP::Response
19
+ def sb_update_advertising_deal: (?advertising_deals: Array[untyped]?) -> HTTP::Response
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ # Generated from lib/amazon_ads/apis/brand_store_edition_publish_versions.rb with RBS::Inline
2
+
3
+ module AmazonAds
4
+ class BrandStoreEditionPublishVersions < API
5
+ # Query store edition publish versions
6
+ # : (edition_id_filter: String, publish_status_filter: String, store_id_filter: String, ?max_results: Integer?, ?next_token: String?) -> HTTP::Response
7
+ def query_brand_store_edition_publish_version: (edition_id_filter: String, publish_status_filter: String, store_id_filter: String, ?max_results: Integer?, ?next_token: String?) -> HTTP::Response
8
+
9
+ # Update store edition publish versions
10
+ # : (?brand_store_edition_publish_versions: Array[untyped]?) -> HTTP::Response
11
+ def update_brand_store_edition_publish_version: (?brand_store_edition_publish_versions: Array[untyped]?) -> HTTP::Response
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ # Generated from lib/amazon_ads/apis/brand_store_editions.rb with RBS::Inline
2
+
3
+ module AmazonAds
4
+ class BrandStoreEditions < API
5
+ # Retrieve brand store page content
6
+ # : (brand_store_id: String, ?next_token: String?, ?max_results: Integer?) -> HTTP::Response
7
+ def list_brand_store_edition: (brand_store_id: String, ?next_token: String?, ?max_results: Integer?) -> HTTP::Response
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # Generated from lib/amazon_ads/apis/brand_store_pages.rb with RBS::Inline
2
+
3
+ module AmazonAds
4
+ class BrandStorePages < API
5
+ # Retrieve brand store page content
6
+ # : (edition_id_filter: String, page_id_filter: String, store_id_filter: String, ?max_results: Integer?, ?next_token: String?, ?store_edition_publish_id_filter: String?) -> HTTP::Response
7
+ def query_brand_store_page: (edition_id_filter: String, page_id_filter: String, store_id_filter: String, ?max_results: Integer?, ?next_token: String?, ?store_edition_publish_id_filter: String?) -> HTTP::Response
8
+ end
9
+ end