leal 0.0.9

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 (127) hide show
  1. checksums.yaml +7 -0
  2. data/.fern/metadata.json +10 -0
  3. data/.fernignore +1 -0
  4. data/.rubocop.yml +103 -0
  5. data/CONTRIBUTING.md +120 -0
  6. data/LICENSE +21 -0
  7. data/README.md +185 -0
  8. data/Rakefile +20 -0
  9. data/custom.gemspec.rb +16 -0
  10. data/lib/leal/cards/client.rb +193 -0
  11. data/lib/leal/cards/types/create_cards_request.rb +13 -0
  12. data/lib/leal/cards/types/create_cards_request_card.rb +33 -0
  13. data/lib/leal/cards/types/create_cards_response.rb +45 -0
  14. data/lib/leal/cards/types/get_cards_request.rb +13 -0
  15. data/lib/leal/cards/types/get_cards_response.rb +45 -0
  16. data/lib/leal/cards/types/list_cards_request.rb +13 -0
  17. data/lib/leal/cards/types/list_cards_response_item.rb +45 -0
  18. data/lib/leal/cards/types/update_cards_request.rb +15 -0
  19. data/lib/leal/cards/types/update_cards_request_card.rb +33 -0
  20. data/lib/leal/cards/types/update_cards_response.rb +45 -0
  21. data/lib/leal/client.rb +62 -0
  22. data/lib/leal/customer_cards/client.rb +203 -0
  23. data/lib/leal/customer_cards/types/get_customer_cards_request.rb +15 -0
  24. data/lib/leal/customer_cards/types/get_customer_cards_response.rb +43 -0
  25. data/lib/leal/customer_cards/types/list_customer_cards_request.rb +13 -0
  26. data/lib/leal/customer_cards/types/list_customer_cards_response_item.rb +37 -0
  27. data/lib/leal/customer_cards/types/redeem_customer_cards_request.rb +17 -0
  28. data/lib/leal/customer_cards/types/redeem_customer_cards_response.rb +13 -0
  29. data/lib/leal/customer_cards/types/redeem_customer_cards_response_redemption.rb +21 -0
  30. data/lib/leal/customer_cards/types/stamp_customer_cards_request.rb +19 -0
  31. data/lib/leal/customer_cards/types/stamp_customer_cards_response.rb +43 -0
  32. data/lib/leal/customers/client.rb +217 -0
  33. data/lib/leal/customers/types/create_customers_request.rb +17 -0
  34. data/lib/leal/customers/types/create_customers_request_customer.rb +23 -0
  35. data/lib/leal/customers/types/create_customers_response.rb +35 -0
  36. data/lib/leal/customers/types/get_customers_request.rb +13 -0
  37. data/lib/leal/customers/types/get_customers_response.rb +35 -0
  38. data/lib/leal/customers/types/list_customers_request.rb +21 -0
  39. data/lib/leal/customers/types/list_customers_response.rb +13 -0
  40. data/lib/leal/customers/types/list_customers_response_pagination.rb +17 -0
  41. data/lib/leal/customers/types/update_customers_request.rb +15 -0
  42. data/lib/leal/customers/types/update_customers_request_customer.rb +23 -0
  43. data/lib/leal/customers/types/update_customers_response.rb +35 -0
  44. data/lib/leal/environment.rb +7 -0
  45. data/lib/leal/errors/api_error.rb +8 -0
  46. data/lib/leal/errors/client_error.rb +17 -0
  47. data/lib/leal/errors/redirect_error.rb +8 -0
  48. data/lib/leal/errors/response_error.rb +42 -0
  49. data/lib/leal/errors/server_error.rb +11 -0
  50. data/lib/leal/errors/timeout_error.rb +8 -0
  51. data/lib/leal/internal/errors/constraint_error.rb +10 -0
  52. data/lib/leal/internal/errors/type_error.rb +10 -0
  53. data/lib/leal/internal/http/base_request.rb +51 -0
  54. data/lib/leal/internal/http/raw_client.rb +265 -0
  55. data/lib/leal/internal/iterators/cursor_item_iterator.rb +28 -0
  56. data/lib/leal/internal/iterators/cursor_page_iterator.rb +63 -0
  57. data/lib/leal/internal/iterators/item_iterator.rb +65 -0
  58. data/lib/leal/internal/iterators/offset_item_iterator.rb +30 -0
  59. data/lib/leal/internal/iterators/offset_page_iterator.rb +103 -0
  60. data/lib/leal/internal/json/request.rb +41 -0
  61. data/lib/leal/internal/json/serializable.rb +25 -0
  62. data/lib/leal/internal/multipart/multipart_encoder.rb +141 -0
  63. data/lib/leal/internal/multipart/multipart_form_data.rb +78 -0
  64. data/lib/leal/internal/multipart/multipart_form_data_part.rb +51 -0
  65. data/lib/leal/internal/multipart/multipart_request.rb +40 -0
  66. data/lib/leal/internal/types/array.rb +47 -0
  67. data/lib/leal/internal/types/boolean.rb +34 -0
  68. data/lib/leal/internal/types/enum.rb +56 -0
  69. data/lib/leal/internal/types/hash.rb +36 -0
  70. data/lib/leal/internal/types/model/field.rb +38 -0
  71. data/lib/leal/internal/types/model.rb +208 -0
  72. data/lib/leal/internal/types/type.rb +35 -0
  73. data/lib/leal/internal/types/union.rb +161 -0
  74. data/lib/leal/internal/types/unknown.rb +15 -0
  75. data/lib/leal/internal/types/utils.rb +116 -0
  76. data/lib/leal/locations/client.rb +225 -0
  77. data/lib/leal/locations/types/create_locations_request.rb +13 -0
  78. data/lib/leal/locations/types/create_locations_request_location.rb +13 -0
  79. data/lib/leal/locations/types/create_locations_response.rb +25 -0
  80. data/lib/leal/locations/types/delete_locations_request.rb +13 -0
  81. data/lib/leal/locations/types/get_locations_request.rb +13 -0
  82. data/lib/leal/locations/types/get_locations_response.rb +25 -0
  83. data/lib/leal/locations/types/list_locations_request.rb +11 -0
  84. data/lib/leal/locations/types/list_locations_response_item.rb +25 -0
  85. data/lib/leal/locations/types/update_locations_request.rb +15 -0
  86. data/lib/leal/locations/types/update_locations_request_location.rb +13 -0
  87. data/lib/leal/locations/types/update_locations_response.rb +25 -0
  88. data/lib/leal/posters/client.rb +232 -0
  89. data/lib/leal/posters/types/create_posters_request.rb +13 -0
  90. data/lib/leal/posters/types/create_posters_request_poster.rb +23 -0
  91. data/lib/leal/posters/types/create_posters_response.rb +37 -0
  92. data/lib/leal/posters/types/delete_posters_request.rb +13 -0
  93. data/lib/leal/posters/types/get_posters_request.rb +13 -0
  94. data/lib/leal/posters/types/get_posters_response.rb +37 -0
  95. data/lib/leal/posters/types/list_posters_request.rb +15 -0
  96. data/lib/leal/posters/types/list_posters_response_item.rb +37 -0
  97. data/lib/leal/posters/types/update_posters_request.rb +15 -0
  98. data/lib/leal/posters/types/update_posters_request_poster.rb +21 -0
  99. data/lib/leal/posters/types/update_posters_response.rb +37 -0
  100. data/lib/leal/rewards/client.rb +233 -0
  101. data/lib/leal/rewards/types/create_rewards_request.rb +13 -0
  102. data/lib/leal/rewards/types/create_rewards_request_reward.rb +21 -0
  103. data/lib/leal/rewards/types/create_rewards_response.rb +29 -0
  104. data/lib/leal/rewards/types/delete_rewards_request.rb +13 -0
  105. data/lib/leal/rewards/types/get_rewards_request.rb +13 -0
  106. data/lib/leal/rewards/types/get_rewards_response.rb +29 -0
  107. data/lib/leal/rewards/types/list_rewards_request.rb +15 -0
  108. data/lib/leal/rewards/types/list_rewards_response_item.rb +29 -0
  109. data/lib/leal/rewards/types/update_rewards_request.rb +15 -0
  110. data/lib/leal/rewards/types/update_rewards_request_reward.rb +19 -0
  111. data/lib/leal/rewards/types/update_rewards_response.rb +29 -0
  112. data/lib/leal/status/client.rb +53 -0
  113. data/lib/leal/status/types/check_status_response.rb +23 -0
  114. data/lib/leal/status/types/check_status_response_rate_limit.rb +15 -0
  115. data/lib/leal/stores/client.rb +130 -0
  116. data/lib/leal/stores/types/get_stores_request.rb +11 -0
  117. data/lib/leal/stores/types/get_stores_response.rb +31 -0
  118. data/lib/leal/stores/types/list_stores_response_item.rb +31 -0
  119. data/lib/leal/stores/types/update_stores_request.rb +13 -0
  120. data/lib/leal/stores/types/update_stores_request_account.rb +13 -0
  121. data/lib/leal/stores/types/update_stores_response.rb +31 -0
  122. data/lib/leal/types/error.rb +13 -0
  123. data/lib/leal/types/error_errors.rb +14 -0
  124. data/lib/leal/version.rb +5 -0
  125. data/lib/leal.rb +120 -0
  126. data/reference.md +2414 -0
  127. metadata +168 -0
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module Cards
5
+ module Types
6
+ class CreateCardsRequestCard < Internal::Types::Model
7
+ field :card_color, -> { String }, optional: true, nullable: false
8
+
9
+ field :header_text, -> { String }, optional: true, nullable: false
10
+
11
+ field :initial_stamps, -> { Integer }, optional: true, nullable: false
12
+
13
+ field :name, -> { String }, optional: false, nullable: false
14
+
15
+ field :stamp_background_color, -> { String }, optional: true, nullable: false
16
+
17
+ field :stamp_color, -> { String }, optional: true, nullable: false
18
+
19
+ field :stamp_icon, -> { String }, optional: true, nullable: false
20
+
21
+ field :stamps_required, -> { Integer }, optional: true, nullable: false
22
+
23
+ field :strip_color, -> { String }, optional: true, nullable: false
24
+
25
+ field :strip_preset, -> { String }, optional: true, nullable: false
26
+
27
+ field :strip_type, -> { String }, optional: true, nullable: false
28
+
29
+ field :text_color, -> { String }, optional: true, nullable: false
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module Cards
5
+ module Types
6
+ class CreateCardsResponse < Internal::Types::Model
7
+ field :archived_at, -> { String }, optional: false, nullable: false
8
+
9
+ field :card_color, -> { String }, optional: false, nullable: false
10
+
11
+ field :created_at, -> { String }, optional: false, nullable: false
12
+
13
+ field :customer_cards_count, -> { Integer }, optional: false, nullable: false
14
+
15
+ field :header_text, -> { String }, optional: false, nullable: false
16
+
17
+ field :id, -> { Integer }, optional: false, nullable: false
18
+
19
+ field :initial_stamps, -> { Integer }, optional: false, nullable: false
20
+
21
+ field :name, -> { String }, optional: false, nullable: false
22
+
23
+ field :rewards_count, -> { Integer }, optional: false, nullable: false
24
+
25
+ field :stamp_background_color, -> { String }, optional: false, nullable: false
26
+
27
+ field :stamp_color, -> { String }, optional: false, nullable: false
28
+
29
+ field :stamp_icon, -> { String }, optional: false, nullable: false
30
+
31
+ field :stamps_required, -> { Integer }, optional: false, nullable: false
32
+
33
+ field :strip_color, -> { String }, optional: false, nullable: false
34
+
35
+ field :strip_preset, -> { String }, optional: false, nullable: false
36
+
37
+ field :strip_type, -> { String }, optional: false, nullable: false
38
+
39
+ field :text_color, -> { String }, optional: false, nullable: false
40
+
41
+ field :updated_at, -> { String }, optional: false, nullable: false
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module Cards
5
+ module Types
6
+ class GetCardsRequest < Internal::Types::Model
7
+ field :account_id, -> { Integer }, optional: false, nullable: false
8
+
9
+ field :id, -> { Integer }, optional: false, nullable: false
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module Cards
5
+ module Types
6
+ class GetCardsResponse < Internal::Types::Model
7
+ field :archived_at, -> { String }, optional: false, nullable: false
8
+
9
+ field :card_color, -> { String }, optional: false, nullable: false
10
+
11
+ field :created_at, -> { String }, optional: false, nullable: false
12
+
13
+ field :customer_cards_count, -> { Integer }, optional: false, nullable: false
14
+
15
+ field :header_text, -> { String }, optional: false, nullable: false
16
+
17
+ field :id, -> { Integer }, optional: false, nullable: false
18
+
19
+ field :initial_stamps, -> { Integer }, optional: false, nullable: false
20
+
21
+ field :name, -> { String }, optional: false, nullable: false
22
+
23
+ field :rewards_count, -> { Integer }, optional: false, nullable: false
24
+
25
+ field :stamp_background_color, -> { String }, optional: false, nullable: false
26
+
27
+ field :stamp_color, -> { String }, optional: false, nullable: false
28
+
29
+ field :stamp_icon, -> { String }, optional: false, nullable: false
30
+
31
+ field :stamps_required, -> { Integer }, optional: false, nullable: false
32
+
33
+ field :strip_color, -> { String }, optional: false, nullable: false
34
+
35
+ field :strip_preset, -> { String }, optional: false, nullable: false
36
+
37
+ field :strip_type, -> { String }, optional: false, nullable: false
38
+
39
+ field :text_color, -> { String }, optional: false, nullable: false
40
+
41
+ field :updated_at, -> { String }, optional: false, nullable: false
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module Cards
5
+ module Types
6
+ class ListCardsRequest < Internal::Types::Model
7
+ field :account_id, -> { Integer }, optional: false, nullable: false
8
+
9
+ field :scope, -> { String }, optional: true, nullable: false
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module Cards
5
+ module Types
6
+ class ListCardsResponseItem < Internal::Types::Model
7
+ field :archived_at, -> { String }, optional: false, nullable: false
8
+
9
+ field :card_color, -> { String }, optional: false, nullable: false
10
+
11
+ field :created_at, -> { String }, optional: false, nullable: false
12
+
13
+ field :customer_cards_count, -> { Integer }, optional: false, nullable: false
14
+
15
+ field :header_text, -> { String }, optional: false, nullable: false
16
+
17
+ field :id, -> { Integer }, optional: false, nullable: false
18
+
19
+ field :initial_stamps, -> { Integer }, optional: false, nullable: false
20
+
21
+ field :name, -> { String }, optional: false, nullable: false
22
+
23
+ field :rewards_count, -> { Integer }, optional: false, nullable: false
24
+
25
+ field :stamp_background_color, -> { String }, optional: false, nullable: false
26
+
27
+ field :stamp_color, -> { String }, optional: false, nullable: false
28
+
29
+ field :stamp_icon, -> { String }, optional: false, nullable: false
30
+
31
+ field :stamps_required, -> { Integer }, optional: false, nullable: false
32
+
33
+ field :strip_color, -> { String }, optional: false, nullable: false
34
+
35
+ field :strip_preset, -> { String }, optional: false, nullable: false
36
+
37
+ field :strip_type, -> { String }, optional: false, nullable: false
38
+
39
+ field :text_color, -> { String }, optional: false, nullable: false
40
+
41
+ field :updated_at, -> { String }, optional: false, nullable: false
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module Cards
5
+ module Types
6
+ class UpdateCardsRequest < Internal::Types::Model
7
+ field :account_id, -> { Integer }, optional: false, nullable: false
8
+
9
+ field :id, -> { Integer }, optional: false, nullable: false
10
+
11
+ field :card, -> { Leal::Cards::Types::UpdateCardsRequestCard }, optional: false, nullable: false
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module Cards
5
+ module Types
6
+ class UpdateCardsRequestCard < Internal::Types::Model
7
+ field :card_color, -> { String }, optional: true, nullable: false
8
+
9
+ field :header_text, -> { String }, optional: true, nullable: false
10
+
11
+ field :initial_stamps, -> { Integer }, optional: true, nullable: false
12
+
13
+ field :name, -> { String }, optional: true, nullable: false
14
+
15
+ field :stamp_background_color, -> { String }, optional: true, nullable: false
16
+
17
+ field :stamp_color, -> { String }, optional: true, nullable: false
18
+
19
+ field :stamp_icon, -> { String }, optional: true, nullable: false
20
+
21
+ field :stamps_required, -> { Integer }, optional: true, nullable: false
22
+
23
+ field :strip_color, -> { String }, optional: true, nullable: false
24
+
25
+ field :strip_preset, -> { String }, optional: true, nullable: false
26
+
27
+ field :strip_type, -> { String }, optional: true, nullable: false
28
+
29
+ field :text_color, -> { String }, optional: true, nullable: false
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module Cards
5
+ module Types
6
+ class UpdateCardsResponse < Internal::Types::Model
7
+ field :archived_at, -> { String }, optional: false, nullable: false
8
+
9
+ field :card_color, -> { String }, optional: false, nullable: false
10
+
11
+ field :created_at, -> { String }, optional: false, nullable: false
12
+
13
+ field :customer_cards_count, -> { Integer }, optional: false, nullable: false
14
+
15
+ field :header_text, -> { String }, optional: false, nullable: false
16
+
17
+ field :id, -> { Integer }, optional: false, nullable: false
18
+
19
+ field :initial_stamps, -> { Integer }, optional: false, nullable: false
20
+
21
+ field :name, -> { String }, optional: false, nullable: false
22
+
23
+ field :rewards_count, -> { Integer }, optional: false, nullable: false
24
+
25
+ field :stamp_background_color, -> { String }, optional: false, nullable: false
26
+
27
+ field :stamp_color, -> { String }, optional: false, nullable: false
28
+
29
+ field :stamp_icon, -> { String }, optional: false, nullable: false
30
+
31
+ field :stamps_required, -> { Integer }, optional: false, nullable: false
32
+
33
+ field :strip_color, -> { String }, optional: false, nullable: false
34
+
35
+ field :strip_preset, -> { String }, optional: false, nullable: false
36
+
37
+ field :strip_type, -> { String }, optional: false, nullable: false
38
+
39
+ field :text_color, -> { String }, optional: false, nullable: false
40
+
41
+ field :updated_at, -> { String }, optional: false, nullable: false
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ class Client
5
+ # @param token [String]
6
+ # @param base_url [String, nil]
7
+ # @param max_retries [Integer]
8
+ #
9
+ # @return [void]
10
+ def initialize(token:, base_url: nil, max_retries: 2)
11
+ @raw_client = Leal::Internal::Http::RawClient.new(
12
+ base_url: base_url || Leal::Environment::PRODUCTION,
13
+ headers: {
14
+ "User-Agent" => "leal/0.0.9",
15
+ "X-Fern-Language" => "Ruby",
16
+ Authorization: "Bearer #{token}"
17
+ },
18
+ max_retries: max_retries
19
+ )
20
+ end
21
+
22
+ # @return [Leal::Stores::Client]
23
+ def stores
24
+ @stores ||= Leal::Stores::Client.new(client: @raw_client)
25
+ end
26
+
27
+ # @return [Leal::Cards::Client]
28
+ def cards
29
+ @cards ||= Leal::Cards::Client.new(client: @raw_client)
30
+ end
31
+
32
+ # @return [Leal::Customers::Client]
33
+ def customers
34
+ @customers ||= Leal::Customers::Client.new(client: @raw_client)
35
+ end
36
+
37
+ # @return [Leal::CustomerCards::Client]
38
+ def customer_cards
39
+ @customer_cards ||= Leal::CustomerCards::Client.new(client: @raw_client)
40
+ end
41
+
42
+ # @return [Leal::Locations::Client]
43
+ def locations
44
+ @locations ||= Leal::Locations::Client.new(client: @raw_client)
45
+ end
46
+
47
+ # @return [Leal::Posters::Client]
48
+ def posters
49
+ @posters ||= Leal::Posters::Client.new(client: @raw_client)
50
+ end
51
+
52
+ # @return [Leal::Rewards::Client]
53
+ def rewards
54
+ @rewards ||= Leal::Rewards::Client.new(client: @raw_client)
55
+ end
56
+
57
+ # @return [Leal::Status::Client]
58
+ def status
59
+ @status ||= Leal::Status::Client.new(client: @raw_client)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,203 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module CustomerCards
5
+ class Client
6
+ # @param client [Leal::Internal::Http::RawClient]
7
+ #
8
+ # @return [void]
9
+ def initialize(client:)
10
+ @client = client
11
+ end
12
+
13
+ # Returns all loyalty cards enrolled for a specific customer, including stamp progress,
14
+ # status, wallet pass installation state, and wallet pass URLs (`apple_wallet_url` and
15
+ # `google_wallet_url`) that you can use to let customers add their loyalty card to
16
+ # Apple Wallet or Google Wallet from your own app or website.
17
+ #
18
+ # @param request_options [Hash]
19
+ # @param params [Hash]
20
+ # @option request_options [String] :base_url
21
+ # @option request_options [Hash{String => Object}] :additional_headers
22
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
23
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
24
+ # @option request_options [Integer] :timeout_in_seconds
25
+ # @option params [Integer] :account_id
26
+ # @option params [Integer] :customer_id
27
+ #
28
+ # @example
29
+ # client.customer_cards.list(
30
+ # account_id: 1,
31
+ # customer_id: 1
32
+ # )
33
+ #
34
+ # @return [Array[Leal::CustomerCards::Types::ListCustomerCardsResponseItem]]
35
+ def list(request_options: {}, **params)
36
+ params = Leal::Internal::Types::Utils.normalize_keys(params)
37
+ request = Leal::Internal::JSON::Request.new(
38
+ base_url: request_options[:base_url],
39
+ method: "GET",
40
+ path: "api/v1/accounts/#{URI.encode_uri_component(params[:account_id].to_s)}/customers/#{URI.encode_uri_component(params[:customer_id].to_s)}/customer_cards",
41
+ request_options: request_options
42
+ )
43
+ begin
44
+ response = @client.send(request)
45
+ rescue Net::HTTPRequestTimeout
46
+ raise Leal::Errors::TimeoutError
47
+ end
48
+ code = response.code.to_i
49
+ return if code.between?(200, 299)
50
+
51
+ error_class = Leal::Errors::ResponseError.subclass_for_code(code)
52
+ raise error_class.new(response.body, code: code)
53
+ end
54
+
55
+ # Returns detailed information about a specific customer card, including stamp progress,
56
+ # a list of rewards the customer has earned enough stamps to redeem, and wallet pass URLs
57
+ # (`apple_wallet_url` and `google_wallet_url`) for adding the card to Apple Wallet or
58
+ # Google Wallet.
59
+ #
60
+ # @param request_options [Hash]
61
+ # @param params [Hash]
62
+ # @option request_options [String] :base_url
63
+ # @option request_options [Hash{String => Object}] :additional_headers
64
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
65
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
66
+ # @option request_options [Integer] :timeout_in_seconds
67
+ # @option params [Integer] :account_id
68
+ # @option params [Integer] :customer_id
69
+ # @option params [Integer] :id
70
+ #
71
+ # @example
72
+ # client.customer_cards.get(
73
+ # account_id: 1,
74
+ # customer_id: 1,
75
+ # id: 1
76
+ # )
77
+ #
78
+ # @return [Leal::CustomerCards::Types::GetCustomerCardsResponse]
79
+ def get(request_options: {}, **params)
80
+ params = Leal::Internal::Types::Utils.normalize_keys(params)
81
+ request = Leal::Internal::JSON::Request.new(
82
+ base_url: request_options[:base_url],
83
+ method: "GET",
84
+ path: "api/v1/accounts/#{URI.encode_uri_component(params[:account_id].to_s)}/customers/#{URI.encode_uri_component(params[:customer_id].to_s)}/customer_cards/#{URI.encode_uri_component(params[:id].to_s)}",
85
+ request_options: request_options
86
+ )
87
+ begin
88
+ response = @client.send(request)
89
+ rescue Net::HTTPRequestTimeout
90
+ raise Leal::Errors::TimeoutError
91
+ end
92
+ code = response.code.to_i
93
+ if code.between?(200, 299)
94
+ Leal::CustomerCards::Types::GetCustomerCardsResponse.load(response.body)
95
+ else
96
+ error_class = Leal::Errors::ResponseError.subclass_for_code(code)
97
+ raise error_class.new(response.body, code: code)
98
+ end
99
+ end
100
+
101
+ # Redeems a reward for a customer, deducting the required stamps from their card.
102
+ # The customer must have enough stamps on this card to cover the reward's cost.
103
+ # Triggers wallet pass updates and push notifications.
104
+ #
105
+ # @param request_options [Hash]
106
+ # @param params [Leal::CustomerCards::Types::RedeemCustomerCardsRequest]
107
+ # @option request_options [String] :base_url
108
+ # @option request_options [Hash{String => Object}] :additional_headers
109
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
110
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
111
+ # @option request_options [Integer] :timeout_in_seconds
112
+ # @option params [Integer] :account_id
113
+ # @option params [Integer] :customer_id
114
+ # @option params [Integer] :id
115
+ #
116
+ # @example
117
+ # client.customer_cards.redeem(
118
+ # account_id: 1,
119
+ # customer_id: 1,
120
+ # id: 1,
121
+ # reward_id: 1
122
+ # )
123
+ #
124
+ # @return [Leal::CustomerCards::Types::RedeemCustomerCardsResponse]
125
+ def redeem(request_options: {}, **params)
126
+ params = Leal::Internal::Types::Utils.normalize_keys(params)
127
+ request_data = Leal::CustomerCards::Types::RedeemCustomerCardsRequest.new(params).to_h
128
+ non_body_param_names = %w[account_id customer_id id]
129
+ body = request_data.except(*non_body_param_names)
130
+
131
+ request = Leal::Internal::JSON::Request.new(
132
+ base_url: request_options[:base_url],
133
+ method: "POST",
134
+ path: "api/v1/accounts/#{URI.encode_uri_component(params[:account_id].to_s)}/customers/#{URI.encode_uri_component(params[:customer_id].to_s)}/customer_cards/#{URI.encode_uri_component(params[:id].to_s)}/redeem",
135
+ body: body,
136
+ request_options: request_options
137
+ )
138
+ begin
139
+ response = @client.send(request)
140
+ rescue Net::HTTPRequestTimeout
141
+ raise Leal::Errors::TimeoutError
142
+ end
143
+ code = response.code.to_i
144
+ if code.between?(200, 299)
145
+ Leal::CustomerCards::Types::RedeemCustomerCardsResponse.load(response.body)
146
+ else
147
+ error_class = Leal::Errors::ResponseError.subclass_for_code(code)
148
+ raise error_class.new(response.body, code: code)
149
+ end
150
+ end
151
+
152
+ # Adds stamps to a customer's loyalty card. Triggers ledger entries, wallet pass updates,
153
+ # and push notifications. Pass `skip_notifications` to stamp silently.
154
+ #
155
+ # @param request_options [Hash]
156
+ # @param params [Leal::CustomerCards::Types::StampCustomerCardsRequest]
157
+ # @option request_options [String] :base_url
158
+ # @option request_options [Hash{String => Object}] :additional_headers
159
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
160
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
161
+ # @option request_options [Integer] :timeout_in_seconds
162
+ # @option params [Integer] :account_id
163
+ # @option params [Integer] :customer_id
164
+ # @option params [Integer] :id
165
+ #
166
+ # @example
167
+ # client.customer_cards.stamp(
168
+ # account_id: 1,
169
+ # customer_id: 1,
170
+ # id: 1,
171
+ # stamps: 1
172
+ # )
173
+ #
174
+ # @return [Leal::CustomerCards::Types::StampCustomerCardsResponse]
175
+ def stamp(request_options: {}, **params)
176
+ params = Leal::Internal::Types::Utils.normalize_keys(params)
177
+ request_data = Leal::CustomerCards::Types::StampCustomerCardsRequest.new(params).to_h
178
+ non_body_param_names = %w[account_id customer_id id]
179
+ body = request_data.except(*non_body_param_names)
180
+
181
+ request = Leal::Internal::JSON::Request.new(
182
+ base_url: request_options[:base_url],
183
+ method: "POST",
184
+ path: "api/v1/accounts/#{URI.encode_uri_component(params[:account_id].to_s)}/customers/#{URI.encode_uri_component(params[:customer_id].to_s)}/customer_cards/#{URI.encode_uri_component(params[:id].to_s)}/stamp",
185
+ body: body,
186
+ request_options: request_options
187
+ )
188
+ begin
189
+ response = @client.send(request)
190
+ rescue Net::HTTPRequestTimeout
191
+ raise Leal::Errors::TimeoutError
192
+ end
193
+ code = response.code.to_i
194
+ if code.between?(200, 299)
195
+ Leal::CustomerCards::Types::StampCustomerCardsResponse.load(response.body)
196
+ else
197
+ error_class = Leal::Errors::ResponseError.subclass_for_code(code)
198
+ raise error_class.new(response.body, code: code)
199
+ end
200
+ end
201
+ end
202
+ end
203
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module CustomerCards
5
+ module Types
6
+ class GetCustomerCardsRequest < Internal::Types::Model
7
+ field :account_id, -> { Integer }, optional: false, nullable: false
8
+
9
+ field :customer_id, -> { Integer }, optional: false, nullable: false
10
+
11
+ field :id, -> { Integer }, optional: false, nullable: false
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module CustomerCards
5
+ module Types
6
+ class GetCustomerCardsResponse < Internal::Types::Model
7
+ field :account_id, -> { Integer }, optional: false, nullable: false
8
+
9
+ field :apple_wallet_url, -> { String }, optional: false, nullable: false
10
+
11
+ field :available_rewards, -> { Internal::Types::Array[String] }, optional: false, nullable: false
12
+
13
+ field :card_id, -> { Integer }, optional: false, nullable: false
14
+
15
+ field :card_name, -> { String }, optional: false, nullable: false
16
+
17
+ field :created_at, -> { String }, optional: false, nullable: false
18
+
19
+ field :customer_id, -> { Integer }, optional: false, nullable: false
20
+
21
+ field :google_wallet_url, -> { String }, optional: false, nullable: false
22
+
23
+ field :id, -> { Integer }, optional: false, nullable: false
24
+
25
+ field :issued_at, -> { String }, optional: false, nullable: false
26
+
27
+ field :pass_installed, -> { Internal::Types::Boolean }, optional: false, nullable: false
28
+
29
+ field :progress_percentage, -> { Integer }, optional: false, nullable: false
30
+
31
+ field :stamps_count, -> { Integer }, optional: false, nullable: false
32
+
33
+ field :stamps_remaining, -> { Integer }, optional: false, nullable: false
34
+
35
+ field :status, -> { String }, optional: false, nullable: false
36
+
37
+ field :updated_at, -> { String }, optional: false, nullable: false
38
+
39
+ field :uuid, -> { String }, optional: false, nullable: false
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module CustomerCards
5
+ module Types
6
+ class ListCustomerCardsRequest < Internal::Types::Model
7
+ field :account_id, -> { Integer }, optional: false, nullable: false
8
+
9
+ field :customer_id, -> { Integer }, optional: false, nullable: false
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module CustomerCards
5
+ module Types
6
+ class ListCustomerCardsResponseItem < Internal::Types::Model
7
+ field :apple_wallet_url, -> { String }, optional: false, nullable: false
8
+
9
+ field :card_id, -> { Integer }, optional: false, nullable: false
10
+
11
+ field :card_name, -> { String }, optional: false, nullable: false
12
+
13
+ field :created_at, -> { String }, optional: false, nullable: false
14
+
15
+ field :google_wallet_url, -> { String }, optional: false, nullable: false
16
+
17
+ field :id, -> { Integer }, optional: false, nullable: false
18
+
19
+ field :issued_at, -> { String }, optional: false, nullable: false
20
+
21
+ field :pass_installed, -> { Internal::Types::Boolean }, optional: false, nullable: false
22
+
23
+ field :progress_percentage, -> { Integer }, optional: false, nullable: false
24
+
25
+ field :stamps_count, -> { Integer }, optional: false, nullable: false
26
+
27
+ field :stamps_remaining, -> { Integer }, optional: false, nullable: false
28
+
29
+ field :status, -> { String }, optional: false, nullable: false
30
+
31
+ field :updated_at, -> { String }, optional: false, nullable: false
32
+
33
+ field :uuid, -> { String }, optional: false, nullable: false
34
+ end
35
+ end
36
+ end
37
+ end