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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b7a50fc10a33a9d250f2d95fad23926d9930bca7762a56e6728573a1d6ea6c35
4
+ data.tar.gz: b826c32f1a986ea1948374c52de9e33139688840bc4729c26305ba586f0fe8d1
5
+ SHA512:
6
+ metadata.gz: cf8f75721957d4e33da42d9f39f9a08d7c9c0d03df1e7ddf40b725a4170387478a335fe5ed4de8dec0a125cbe7d6ba4781a952081e3408b0317c946162cd2bd2
7
+ data.tar.gz: 02efc7012951dda3b53116272d52f81f0fb5ba65eefd1f3a48234e1ddbea8fc8eace005b90e9e14a3a993a9c8ee612a0d0e08115c1bf381b03badc1aae1ab579
@@ -0,0 +1,10 @@
1
+ {
2
+ "cliVersion": "5.102.0",
3
+ "generatorName": "fernapi/fern-ruby-sdk",
4
+ "generatorVersion": "1.23.2",
5
+ "originGitCommit": "5fcc3ad90443b60a77b75996645a72767caa6ef4",
6
+ "originGitCommitIsDirty": false,
7
+ "invokedBy": "ci",
8
+ "ciProvider": "github",
9
+ "sdkVersion": "0.0.9"
10
+ }
data/.fernignore ADDED
@@ -0,0 +1 @@
1
+ # Specify files that shouldn't be modified by Fern
data/.rubocop.yml ADDED
@@ -0,0 +1,103 @@
1
+ plugins:
2
+ - rubocop-minitest
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 3.3
6
+ NewCops: enable
7
+
8
+ Style/StringLiterals:
9
+ EnforcedStyle: double_quotes
10
+
11
+ Style/StringLiteralsInInterpolation:
12
+ EnforcedStyle: double_quotes
13
+
14
+ Style/AccessModifierDeclarations:
15
+ Enabled: false
16
+
17
+ Lint/ConstantDefinitionInBlock:
18
+ Enabled: false
19
+
20
+ Metrics/AbcSize:
21
+ Enabled: false
22
+
23
+ Metrics/BlockLength:
24
+ Enabled: false
25
+
26
+ Metrics/ClassLength:
27
+ Enabled: false
28
+
29
+ Metrics/MethodLength:
30
+ Enabled: false
31
+
32
+ Metrics/ParameterLists:
33
+ Enabled: false
34
+
35
+ Metrics/PerceivedComplexity:
36
+ Enabled: false
37
+
38
+ Metrics/CyclomaticComplexity:
39
+ Enabled: false
40
+
41
+ Metrics/ModuleLength:
42
+ Enabled: false
43
+
44
+ Layout/LineLength:
45
+ Enabled: false
46
+
47
+ Naming/VariableNumber:
48
+ EnforcedStyle: normalcase
49
+ Severity: warning
50
+
51
+ Style/Documentation:
52
+ Enabled: false
53
+
54
+ Style/Lambda:
55
+ EnforcedStyle: literal
56
+
57
+ Minitest/MultipleAssertions:
58
+ Enabled: false
59
+
60
+ Minitest/UselessAssertion:
61
+ Enabled: false
62
+
63
+ # Dynamic snippets are code samples for documentation, not standalone Ruby files.
64
+ Style/FrozenStringLiteralComment:
65
+ Exclude:
66
+ - "dynamic-snippets/**/*"
67
+
68
+ # Indent hash elements 2 spaces from the start of the enclosing line rather than
69
+ # aligning with the preceding paren or bracket. Generated code nests hashes inside
70
+ # arrays and method calls; the "consistent" style is more readable there.
71
+ Layout/FirstHashElementIndentation:
72
+ EnforcedStyle: consistent
73
+ Exclude:
74
+ - "dynamic-snippets/**/*"
75
+
76
+ # Match Layout/FirstHashElementIndentation: indent the first argument 2 spaces
77
+ # from the start of the method call's line, regardless of parenthesis position.
78
+ # Dynamic snippets are code samples, not standalone Ruby files; exclude them to
79
+ # keep this config symmetric with Layout/FirstHashElementIndentation above.
80
+ Layout/FirstArgumentIndentation:
81
+ EnforcedStyle: consistent
82
+ Exclude:
83
+ - "dynamic-snippets/**/*"
84
+
85
+ # The generator emits non-idiomatic class names (e.g. Get_With_Query, JSON_)
86
+ # derived from IR type names whose wire form contains underscores or digits.
87
+ # Rubocop never auto-corrected these (naming cops have no autocorrecter), so
88
+ # disabling the cop keeps CI green without changing customer output. Fixing at
89
+ # source would rename public types across every existing SDK and therefore
90
+ # requires a ruby-v2 major-version bump with a generator migration.
91
+ Naming/ClassAndModuleCamelCase:
92
+ Enabled: false
93
+
94
+ # Integer literals are emitted unformatted (e.g. 1000000, not 1_000_000).
95
+ # Rubocop has an autocorrecter for this cop, but the only caller of integer
96
+ # emission is the dynamic-snippets path, which feeds customer-facing surfaces:
97
+ # (1) snippet markdown in reference docs, (2) dynamic-snippets/*.rb sample
98
+ # files. Neither is rubocop-gated (markdown isn't Ruby, dynamic-snippets/**/*
99
+ # is excluded above), so formatting integers there would change docs/dashboard
100
+ # output without any rubocop benefit. Disabling the cop keeps integers raw
101
+ # everywhere and avoids customer-visible diffs.
102
+ Style/NumericLiterals:
103
+ Enabled: false
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,120 @@
1
+ # Contributing
2
+
3
+ Thanks for your interest in contributing to this SDK! This document provides guidelines for contributing to the project.
4
+
5
+ ## Getting Started
6
+
7
+ ### Prerequisites
8
+
9
+ - Ruby 3.0+
10
+ - Bundler
11
+
12
+ ### Installation
13
+
14
+ Install the project dependencies:
15
+
16
+ ```bash
17
+ bundle install
18
+ ```
19
+
20
+ ### Building
21
+
22
+ Build the gem:
23
+
24
+ ```bash
25
+ gem build *.gemspec
26
+ ```
27
+
28
+ ### Testing
29
+
30
+ Run the test suite:
31
+
32
+ ```bash
33
+ bundle exec rspec
34
+ ```
35
+
36
+ ### Linting and Formatting
37
+
38
+ Check code style:
39
+
40
+ ```bash
41
+ bundle exec rubocop
42
+ ```
43
+
44
+ Fix code style issues:
45
+
46
+ ```bash
47
+ bundle exec rubocop -a
48
+ ```
49
+
50
+ ## About Generated Code
51
+
52
+ **Important**: Most files in this SDK are automatically generated by [Fern](https://buildwithfern.com) from the API definition. Direct modifications to generated files will be overwritten the next time the SDK is generated.
53
+
54
+ ### Generated Files
55
+
56
+ The following directories contain generated code:
57
+ - `lib/` - API client classes and types
58
+ - Most Ruby files in the project
59
+
60
+ ### How to Customize
61
+
62
+ If you need to customize the SDK, you have two options:
63
+
64
+ #### Option 1: Use `.fernignore`
65
+
66
+ For custom code that should persist across SDK regenerations:
67
+
68
+ 1. Create a `.fernignore` file in the project root
69
+ 2. Add file patterns for files you want to preserve (similar to `.gitignore` syntax)
70
+ 3. Add your custom code to those files
71
+
72
+ Files listed in `.fernignore` will not be overwritten when the SDK is regenerated.
73
+
74
+ For more information, see the [Fern documentation on custom code](https://buildwithfern.com/learn/sdks/overview/custom-code).
75
+
76
+ #### Option 2: Contribute to the Generator
77
+
78
+ If you want to change how code is generated for all users of this SDK:
79
+
80
+ 1. The Ruby SDK generator lives in the [Fern repository](https://github.com/fern-api/fern)
81
+ 2. Generator code is located at `generators/ruby-v2/`
82
+ 3. Follow the [Fern contributing guidelines](https://github.com/fern-api/fern/blob/main/CONTRIBUTING.md)
83
+ 4. Submit a pull request with your changes to the generator
84
+
85
+ This approach is best for:
86
+ - Bug fixes in generated code
87
+ - New features that would benefit all users
88
+ - Improvements to code generation patterns
89
+
90
+ ## Making Changes
91
+
92
+ ### Workflow
93
+
94
+ 1. Create a new branch for your changes
95
+ 2. Make your modifications
96
+ 3. Run tests to ensure nothing breaks: `bundle exec rspec`
97
+ 4. Run linting: `bundle exec rubocop`
98
+ 5. Build the gem: `gem build *.gemspec`
99
+ 6. Commit your changes with a clear commit message
100
+ 7. Push your branch and create a pull request
101
+
102
+ ### Commit Messages
103
+
104
+ Write clear, descriptive commit messages that explain what changed and why.
105
+
106
+ ### Code Style
107
+
108
+ This project uses RuboCop for code formatting. Run `bundle exec rubocop` before committing to ensure your code meets the project's style guidelines.
109
+
110
+ ## Questions or Issues?
111
+
112
+ If you have questions or run into issues:
113
+
114
+ 1. Check the [Fern documentation](https://buildwithfern.com)
115
+ 2. Search existing [GitHub issues](https://github.com/fern-api/fern/issues)
116
+ 3. Open a new issue if your question hasn't been addressed
117
+
118
+ ## License
119
+
120
+ By contributing to this project, you agree that your contributions will be licensed under the same license as the project.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Leal.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,185 @@
1
+ # Leal Ruby Library
2
+
3
+ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Flealhq%2Fleal-ruby-sdk)
4
+
5
+ Digital loyalty stamp cards in Apple Wallet and Google Wallet, for local
6
+ businesses. This library covers the whole [Leal](https://www.getleal.com)
7
+ API, so you can enrol customers, add stamps, redeem rewards and read a
8
+ card's wallet links from your own application.
9
+
10
+ - Guides and a page for every language: [www.getleal.com/developers](https://www.getleal.com/developers)
11
+ - Create an API token: [app.getleal.com/api_tokens](https://app.getleal.com/api_tokens)
12
+ - The OpenAPI description these libraries are built from: [www.getleal.com/openapi.json](https://www.getleal.com/openapi.json)
13
+
14
+
15
+ ## Table of Contents
16
+
17
+ - [Documentation](#documentation)
18
+ - [Reference](#reference)
19
+ - [Usage](#usage)
20
+ - [Environments](#environments)
21
+ - [Errors](#errors)
22
+ - [Advanced](#advanced)
23
+ - [Retries](#retries)
24
+ - [Timeouts](#timeouts)
25
+ - [Additional Headers](#additional-headers)
26
+ - [Additional Query Parameters](#additional-query-parameters)
27
+ - [Contributing](#contributing)
28
+
29
+ ## Documentation
30
+
31
+ API reference documentation is available [here](https://app.getleal.com/docs/api.html).
32
+
33
+ ## Reference
34
+
35
+ A full reference for this library is available [here](https://github.com/lealhq/leal-ruby-sdk/blob/HEAD/./reference.md).
36
+
37
+ ## Usage
38
+
39
+ Instantiate and use the client with the following:
40
+
41
+ ```ruby
42
+ require "leal"
43
+
44
+ client = Leal::Client.new(token: "<token>")
45
+
46
+ client.customer_cards.stamp(
47
+ account_id: 1,
48
+ customer_id: 1,
49
+ id: 1,
50
+ stamps: 1
51
+ )
52
+ ```
53
+
54
+ ## Environments
55
+
56
+ This SDK allows you to configure different environments or custom URLs for API requests. You can either use the predefined environments or specify your own custom URL.
57
+ ### Environments
58
+ ```ruby
59
+ require "leal"
60
+
61
+ leal = Leal::Client.new(
62
+ base_url: Leal::Environment::PRODUCTION
63
+ )
64
+ ```
65
+
66
+ ### Custom URL
67
+ ```ruby
68
+ require "leal"
69
+
70
+ client = Leal::Client.new(
71
+ base_url: "https://example.com"
72
+ )
73
+ ```
74
+
75
+ ## Errors
76
+
77
+ Failed API calls will raise errors that can be rescued from granularly.
78
+
79
+ ```ruby
80
+ require "leal"
81
+
82
+ client = Leal::Client.new(
83
+ base_url: "https://example.com"
84
+ )
85
+
86
+ begin
87
+ result = client.customer_cards.stamp
88
+ rescue Leal::Errors::TimeoutError
89
+ puts "API didn't respond before our timeout elapsed"
90
+ rescue Leal::Errors::ServiceUnavailableError
91
+ puts "API returned status 503, is probably overloaded, try again later"
92
+ rescue Leal::Errors::ServerError
93
+ puts "API returned some other 5xx status, this is probably a bug"
94
+ rescue Leal::Errors::ResponseError => e
95
+ puts "API returned an unexpected status other than 5xx: #{e.code} #{e.message}"
96
+ rescue Leal::Errors::ApiError => e
97
+ puts "Some other error occurred when calling the API: #{e.message}"
98
+ end
99
+ ```
100
+
101
+ ## Advanced
102
+
103
+ ### Retries
104
+
105
+ The SDK is instrumented with automatic retries. A request will be retried as long as the request is deemed
106
+ retryable and the number of retry attempts has not grown larger than the configured retry limit (default: 2).
107
+
108
+ A request is deemed retryable when any of the following HTTP status codes is returned:
109
+
110
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
111
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
112
+ - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) (Internal Server Error)
113
+
114
+ The `retryStatusCodes` configuration controls which [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) status codes are retried:
115
+
116
+ - `legacy` (default): Retries `408`, `429`, `500`, `502`, `503`, `504`, `521`, `522`, `524`
117
+ - `recommended`: Retries `408`, `429`, `502`, `503`, `504` only (excludes `500 Internal Server Error` to avoid retrying non-idempotent failures)
118
+
119
+ Use the `max_retries` option to configure this behavior.
120
+
121
+ ```ruby
122
+ require "leal"
123
+
124
+ client = Leal::Client.new(
125
+ base_url: "https://example.com",
126
+ max_retries: 3 # Configure max retries (default is 2)
127
+ )
128
+ ```
129
+
130
+ ### Timeouts
131
+
132
+ The SDK defaults to a 60 second timeout. Use the `timeout` option to configure this behavior.
133
+
134
+ ```ruby
135
+ require "leal"
136
+
137
+ response = client.customer_cards.stamp(
138
+ ...,
139
+ timeout: 30 # 30 second timeout
140
+ )
141
+ ```
142
+
143
+ ### Additional Headers
144
+
145
+ If you would like to send additional headers as part of the request, use the `additional_headers` request option.
146
+
147
+ ```ruby
148
+ require "leal"
149
+
150
+ response = client.customer_cards.stamp(
151
+ ...,
152
+ request_options: {
153
+ additional_headers: {
154
+ "X-Custom-Header" => "custom-value"
155
+ }
156
+ }
157
+ )
158
+ ```
159
+
160
+ ### Additional Query Parameters
161
+
162
+ If you would like to send additional query parameters as part of the request, use the `additional_query_parameters` request option.
163
+
164
+ ```ruby
165
+ require "leal"
166
+
167
+ response = client.customer_cards.stamp(
168
+ ...,
169
+ request_options: {
170
+ additional_query_parameters: {
171
+ "custom_param" => "custom-value"
172
+ }
173
+ }
174
+ )
175
+ ```
176
+
177
+ ## Contributing
178
+
179
+ While we value open-source contributions to this SDK, this library is generated programmatically.
180
+ Additions made directly to this library would have to be moved over to our generation code,
181
+ otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
182
+ a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
183
+ an issue first to discuss with us!
184
+
185
+ On the other hand, contributions to the README are always very welcome!
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[test]
13
+
14
+ task lint: %i[rubocop]
15
+
16
+ # Run only the custom test file
17
+ Minitest::TestTask.create(:customtest) do |t|
18
+ t.libs << "test"
19
+ t.test_globs = ["test/custom.test.rb"]
20
+ end
data/custom.gemspec.rb ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Custom gemspec configuration file
4
+ # This file is automatically loaded by the main gemspec file. The 'spec' variable is available
5
+ # in this context from the main gemspec file. You can modify this file to add custom metadata,
6
+ # dependencies, or other gemspec configurations. If you do make changes to this file, you will
7
+ # need to add it to the .fernignore file to prevent your changes from being overwritten.
8
+
9
+ def add_custom_gemspec_data(spec)
10
+ # Example custom configurations (uncomment and modify as needed)
11
+
12
+ # spec.authors = ["Your name"]
13
+ # spec.email = ["your.email@example.com"]
14
+ # spec.homepage = "https://github.com/your-org/leal-ruby"
15
+ # spec.license = "Your license"
16
+ end
@@ -0,0 +1,193 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module Cards
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 loyalty card templates for the specified store. By default, only
14
+ # active (unarchived) cards are returned. Use the `scope` parameter to include
15
+ # archived cards.
16
+ #
17
+ # @param request_options [Hash]
18
+ # @param params [Hash]
19
+ # @option request_options [String] :base_url
20
+ # @option request_options [Hash{String => Object}] :additional_headers
21
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
22
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
23
+ # @option request_options [Integer] :timeout_in_seconds
24
+ # @option params [Integer] :account_id
25
+ # @option params [String, nil] :scope
26
+ #
27
+ # @example
28
+ # client.cards.list(account_id: 1)
29
+ #
30
+ # @return [Array[Leal::Cards::Types::ListCardsResponseItem]]
31
+ def list(request_options: {}, **params)
32
+ params = Leal::Internal::Types::Utils.normalize_keys(params)
33
+ query_params = {}
34
+ query_params["scope"] = params[:scope] if params.key?(:scope)
35
+
36
+ request = Leal::Internal::JSON::Request.new(
37
+ base_url: request_options[:base_url],
38
+ method: "GET",
39
+ path: "api/v1/accounts/#{URI.encode_uri_component(params[:account_id].to_s)}/cards",
40
+ query: query_params,
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
+ # Creates a new loyalty stamp card template for the store. The card defines the
56
+ # visual design (colours, icon, strip) and program rules (stamps required,
57
+ # initial stamps).
58
+ #
59
+ # @param request_options [Hash]
60
+ # @param params [Leal::Cards::Types::CreateCardsRequest]
61
+ # @option request_options [String] :base_url
62
+ # @option request_options [Hash{String => Object}] :additional_headers
63
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
64
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
65
+ # @option request_options [Integer] :timeout_in_seconds
66
+ # @option params [Integer] :account_id
67
+ #
68
+ # @example
69
+ # client.cards.create(
70
+ # account_id: 1,
71
+ # card: {
72
+ # name: "name"
73
+ # }
74
+ # )
75
+ #
76
+ # @return [Leal::Cards::Types::CreateCardsResponse]
77
+ def create(request_options: {}, **params)
78
+ params = Leal::Internal::Types::Utils.normalize_keys(params)
79
+ request_data = Leal::Cards::Types::CreateCardsRequest.new(params).to_h
80
+ non_body_param_names = %w[account_id]
81
+ body = request_data.except(*non_body_param_names)
82
+
83
+ request = Leal::Internal::JSON::Request.new(
84
+ base_url: request_options[:base_url],
85
+ method: "POST",
86
+ path: "api/v1/accounts/#{URI.encode_uri_component(params[:account_id].to_s)}/cards",
87
+ body: body,
88
+ request_options: request_options
89
+ )
90
+ begin
91
+ response = @client.send(request)
92
+ rescue Net::HTTPRequestTimeout
93
+ raise Leal::Errors::TimeoutError
94
+ end
95
+ code = response.code.to_i
96
+ if code.between?(200, 299)
97
+ Leal::Cards::Types::CreateCardsResponse.load(response.body)
98
+ else
99
+ error_class = Leal::Errors::ResponseError.subclass_for_code(code)
100
+ raise error_class.new(response.body, code: code)
101
+ end
102
+ end
103
+
104
+ # Returns a single loyalty card template by ID, including reward and customer card counts.
105
+ #
106
+ # @param request_options [Hash]
107
+ # @param params [Hash]
108
+ # @option request_options [String] :base_url
109
+ # @option request_options [Hash{String => Object}] :additional_headers
110
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
111
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
112
+ # @option request_options [Integer] :timeout_in_seconds
113
+ # @option params [Integer] :account_id
114
+ # @option params [Integer] :id
115
+ #
116
+ # @example
117
+ # client.cards.get(
118
+ # account_id: 1,
119
+ # id: 1
120
+ # )
121
+ #
122
+ # @return [Leal::Cards::Types::GetCardsResponse]
123
+ def get(request_options: {}, **params)
124
+ params = Leal::Internal::Types::Utils.normalize_keys(params)
125
+ request = Leal::Internal::JSON::Request.new(
126
+ base_url: request_options[:base_url],
127
+ method: "GET",
128
+ path: "api/v1/accounts/#{URI.encode_uri_component(params[:account_id].to_s)}/cards/#{URI.encode_uri_component(params[:id].to_s)}",
129
+ request_options: request_options
130
+ )
131
+ begin
132
+ response = @client.send(request)
133
+ rescue Net::HTTPRequestTimeout
134
+ raise Leal::Errors::TimeoutError
135
+ end
136
+ code = response.code.to_i
137
+ if code.between?(200, 299)
138
+ Leal::Cards::Types::GetCardsResponse.load(response.body)
139
+ else
140
+ error_class = Leal::Errors::ResponseError.subclass_for_code(code)
141
+ raise error_class.new(response.body, code: code)
142
+ end
143
+ end
144
+
145
+ # Updates an existing loyalty card template. Only the provided attributes are changed.
146
+ #
147
+ # @param request_options [Hash]
148
+ # @param params [Leal::Cards::Types::UpdateCardsRequest]
149
+ # @option request_options [String] :base_url
150
+ # @option request_options [Hash{String => Object}] :additional_headers
151
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
152
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
153
+ # @option request_options [Integer] :timeout_in_seconds
154
+ # @option params [Integer] :account_id
155
+ # @option params [Integer] :id
156
+ #
157
+ # @example
158
+ # client.cards.update(
159
+ # account_id: 1,
160
+ # id: 1,
161
+ # card: {}
162
+ # )
163
+ #
164
+ # @return [Leal::Cards::Types::UpdateCardsResponse]
165
+ def update(request_options: {}, **params)
166
+ params = Leal::Internal::Types::Utils.normalize_keys(params)
167
+ request_data = Leal::Cards::Types::UpdateCardsRequest.new(params).to_h
168
+ non_body_param_names = %w[account_id id]
169
+ body = request_data.except(*non_body_param_names)
170
+
171
+ request = Leal::Internal::JSON::Request.new(
172
+ base_url: request_options[:base_url],
173
+ method: "PATCH",
174
+ path: "api/v1/accounts/#{URI.encode_uri_component(params[:account_id].to_s)}/cards/#{URI.encode_uri_component(params[:id].to_s)}",
175
+ body: body,
176
+ request_options: request_options
177
+ )
178
+ begin
179
+ response = @client.send(request)
180
+ rescue Net::HTTPRequestTimeout
181
+ raise Leal::Errors::TimeoutError
182
+ end
183
+ code = response.code.to_i
184
+ if code.between?(200, 299)
185
+ Leal::Cards::Types::UpdateCardsResponse.load(response.body)
186
+ else
187
+ error_class = Leal::Errors::ResponseError.subclass_for_code(code)
188
+ raise error_class.new(response.body, code: code)
189
+ end
190
+ end
191
+ end
192
+ end
193
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leal
4
+ module Cards
5
+ module Types
6
+ class CreateCardsRequest < Internal::Types::Model
7
+ field :account_id, -> { Integer }, optional: false, nullable: false
8
+
9
+ field :card, -> { Leal::Cards::Types::CreateCardsRequestCard }, optional: false, nullable: false
10
+ end
11
+ end
12
+ end
13
+ end