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.
- checksums.yaml +7 -0
- data/.fern/metadata.json +10 -0
- data/.fernignore +1 -0
- data/.rubocop.yml +103 -0
- data/CONTRIBUTING.md +120 -0
- data/LICENSE +21 -0
- data/README.md +185 -0
- data/Rakefile +20 -0
- data/custom.gemspec.rb +16 -0
- data/lib/leal/cards/client.rb +193 -0
- data/lib/leal/cards/types/create_cards_request.rb +13 -0
- data/lib/leal/cards/types/create_cards_request_card.rb +33 -0
- data/lib/leal/cards/types/create_cards_response.rb +45 -0
- data/lib/leal/cards/types/get_cards_request.rb +13 -0
- data/lib/leal/cards/types/get_cards_response.rb +45 -0
- data/lib/leal/cards/types/list_cards_request.rb +13 -0
- data/lib/leal/cards/types/list_cards_response_item.rb +45 -0
- data/lib/leal/cards/types/update_cards_request.rb +15 -0
- data/lib/leal/cards/types/update_cards_request_card.rb +33 -0
- data/lib/leal/cards/types/update_cards_response.rb +45 -0
- data/lib/leal/client.rb +62 -0
- data/lib/leal/customer_cards/client.rb +203 -0
- data/lib/leal/customer_cards/types/get_customer_cards_request.rb +15 -0
- data/lib/leal/customer_cards/types/get_customer_cards_response.rb +43 -0
- data/lib/leal/customer_cards/types/list_customer_cards_request.rb +13 -0
- data/lib/leal/customer_cards/types/list_customer_cards_response_item.rb +37 -0
- data/lib/leal/customer_cards/types/redeem_customer_cards_request.rb +17 -0
- data/lib/leal/customer_cards/types/redeem_customer_cards_response.rb +13 -0
- data/lib/leal/customer_cards/types/redeem_customer_cards_response_redemption.rb +21 -0
- data/lib/leal/customer_cards/types/stamp_customer_cards_request.rb +19 -0
- data/lib/leal/customer_cards/types/stamp_customer_cards_response.rb +43 -0
- data/lib/leal/customers/client.rb +217 -0
- data/lib/leal/customers/types/create_customers_request.rb +17 -0
- data/lib/leal/customers/types/create_customers_request_customer.rb +23 -0
- data/lib/leal/customers/types/create_customers_response.rb +35 -0
- data/lib/leal/customers/types/get_customers_request.rb +13 -0
- data/lib/leal/customers/types/get_customers_response.rb +35 -0
- data/lib/leal/customers/types/list_customers_request.rb +21 -0
- data/lib/leal/customers/types/list_customers_response.rb +13 -0
- data/lib/leal/customers/types/list_customers_response_pagination.rb +17 -0
- data/lib/leal/customers/types/update_customers_request.rb +15 -0
- data/lib/leal/customers/types/update_customers_request_customer.rb +23 -0
- data/lib/leal/customers/types/update_customers_response.rb +35 -0
- data/lib/leal/environment.rb +7 -0
- data/lib/leal/errors/api_error.rb +8 -0
- data/lib/leal/errors/client_error.rb +17 -0
- data/lib/leal/errors/redirect_error.rb +8 -0
- data/lib/leal/errors/response_error.rb +42 -0
- data/lib/leal/errors/server_error.rb +11 -0
- data/lib/leal/errors/timeout_error.rb +8 -0
- data/lib/leal/internal/errors/constraint_error.rb +10 -0
- data/lib/leal/internal/errors/type_error.rb +10 -0
- data/lib/leal/internal/http/base_request.rb +51 -0
- data/lib/leal/internal/http/raw_client.rb +265 -0
- data/lib/leal/internal/iterators/cursor_item_iterator.rb +28 -0
- data/lib/leal/internal/iterators/cursor_page_iterator.rb +63 -0
- data/lib/leal/internal/iterators/item_iterator.rb +65 -0
- data/lib/leal/internal/iterators/offset_item_iterator.rb +30 -0
- data/lib/leal/internal/iterators/offset_page_iterator.rb +103 -0
- data/lib/leal/internal/json/request.rb +41 -0
- data/lib/leal/internal/json/serializable.rb +25 -0
- data/lib/leal/internal/multipart/multipart_encoder.rb +141 -0
- data/lib/leal/internal/multipart/multipart_form_data.rb +78 -0
- data/lib/leal/internal/multipart/multipart_form_data_part.rb +51 -0
- data/lib/leal/internal/multipart/multipart_request.rb +40 -0
- data/lib/leal/internal/types/array.rb +47 -0
- data/lib/leal/internal/types/boolean.rb +34 -0
- data/lib/leal/internal/types/enum.rb +56 -0
- data/lib/leal/internal/types/hash.rb +36 -0
- data/lib/leal/internal/types/model/field.rb +38 -0
- data/lib/leal/internal/types/model.rb +208 -0
- data/lib/leal/internal/types/type.rb +35 -0
- data/lib/leal/internal/types/union.rb +161 -0
- data/lib/leal/internal/types/unknown.rb +15 -0
- data/lib/leal/internal/types/utils.rb +116 -0
- data/lib/leal/locations/client.rb +225 -0
- data/lib/leal/locations/types/create_locations_request.rb +13 -0
- data/lib/leal/locations/types/create_locations_request_location.rb +13 -0
- data/lib/leal/locations/types/create_locations_response.rb +25 -0
- data/lib/leal/locations/types/delete_locations_request.rb +13 -0
- data/lib/leal/locations/types/get_locations_request.rb +13 -0
- data/lib/leal/locations/types/get_locations_response.rb +25 -0
- data/lib/leal/locations/types/list_locations_request.rb +11 -0
- data/lib/leal/locations/types/list_locations_response_item.rb +25 -0
- data/lib/leal/locations/types/update_locations_request.rb +15 -0
- data/lib/leal/locations/types/update_locations_request_location.rb +13 -0
- data/lib/leal/locations/types/update_locations_response.rb +25 -0
- data/lib/leal/posters/client.rb +232 -0
- data/lib/leal/posters/types/create_posters_request.rb +13 -0
- data/lib/leal/posters/types/create_posters_request_poster.rb +23 -0
- data/lib/leal/posters/types/create_posters_response.rb +37 -0
- data/lib/leal/posters/types/delete_posters_request.rb +13 -0
- data/lib/leal/posters/types/get_posters_request.rb +13 -0
- data/lib/leal/posters/types/get_posters_response.rb +37 -0
- data/lib/leal/posters/types/list_posters_request.rb +15 -0
- data/lib/leal/posters/types/list_posters_response_item.rb +37 -0
- data/lib/leal/posters/types/update_posters_request.rb +15 -0
- data/lib/leal/posters/types/update_posters_request_poster.rb +21 -0
- data/lib/leal/posters/types/update_posters_response.rb +37 -0
- data/lib/leal/rewards/client.rb +233 -0
- data/lib/leal/rewards/types/create_rewards_request.rb +13 -0
- data/lib/leal/rewards/types/create_rewards_request_reward.rb +21 -0
- data/lib/leal/rewards/types/create_rewards_response.rb +29 -0
- data/lib/leal/rewards/types/delete_rewards_request.rb +13 -0
- data/lib/leal/rewards/types/get_rewards_request.rb +13 -0
- data/lib/leal/rewards/types/get_rewards_response.rb +29 -0
- data/lib/leal/rewards/types/list_rewards_request.rb +15 -0
- data/lib/leal/rewards/types/list_rewards_response_item.rb +29 -0
- data/lib/leal/rewards/types/update_rewards_request.rb +15 -0
- data/lib/leal/rewards/types/update_rewards_request_reward.rb +19 -0
- data/lib/leal/rewards/types/update_rewards_response.rb +29 -0
- data/lib/leal/status/client.rb +53 -0
- data/lib/leal/status/types/check_status_response.rb +23 -0
- data/lib/leal/status/types/check_status_response_rate_limit.rb +15 -0
- data/lib/leal/stores/client.rb +130 -0
- data/lib/leal/stores/types/get_stores_request.rb +11 -0
- data/lib/leal/stores/types/get_stores_response.rb +31 -0
- data/lib/leal/stores/types/list_stores_response_item.rb +31 -0
- data/lib/leal/stores/types/update_stores_request.rb +13 -0
- data/lib/leal/stores/types/update_stores_request_account.rb +13 -0
- data/lib/leal/stores/types/update_stores_response.rb +31 -0
- data/lib/leal/types/error.rb +13 -0
- data/lib/leal/types/error_errors.rb +14 -0
- data/lib/leal/version.rb +5 -0
- data/lib/leal.rb +120 -0
- data/reference.md +2414 -0
- metadata +168 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Posters
|
|
5
|
+
module Types
|
|
6
|
+
class CreatePostersRequestPoster < Internal::Types::Model
|
|
7
|
+
field :active, -> { Internal::Types::Boolean }, optional: true, nullable: false
|
|
8
|
+
|
|
9
|
+
field :card_id, -> { Integer }, optional: false, nullable: false
|
|
10
|
+
|
|
11
|
+
field :paper_size, -> { String }, optional: true, nullable: false
|
|
12
|
+
|
|
13
|
+
field :primary_color, -> { String }, optional: true, nullable: false
|
|
14
|
+
|
|
15
|
+
field :secondary_color, -> { String }, optional: true, nullable: false
|
|
16
|
+
|
|
17
|
+
field :text_color, -> { String }, optional: true, nullable: false
|
|
18
|
+
|
|
19
|
+
field :title, -> { String }, optional: true, nullable: false
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Posters
|
|
5
|
+
module Types
|
|
6
|
+
class CreatePostersResponse < Internal::Types::Model
|
|
7
|
+
field :account_id, -> { Integer }, optional: false, nullable: false
|
|
8
|
+
|
|
9
|
+
field :active, -> { Internal::Types::Boolean }, optional: false, nullable: false
|
|
10
|
+
|
|
11
|
+
field :card_id, -> { Integer }, optional: false, nullable: false
|
|
12
|
+
|
|
13
|
+
field :created_at, -> { String }, optional: false, nullable: false
|
|
14
|
+
|
|
15
|
+
field :display_url, -> { String }, optional: false, nullable: false
|
|
16
|
+
|
|
17
|
+
field :id, -> { Integer }, optional: false, nullable: false
|
|
18
|
+
|
|
19
|
+
field :paper_size, -> { String }, optional: false, nullable: false
|
|
20
|
+
|
|
21
|
+
field :primary_color, -> { String }, optional: false, nullable: false
|
|
22
|
+
|
|
23
|
+
field :qr_code_url, -> { String }, optional: false, nullable: false
|
|
24
|
+
|
|
25
|
+
field :secondary_color, -> { String }, optional: false, nullable: false
|
|
26
|
+
|
|
27
|
+
field :signup_url, -> { String }, optional: false, nullable: false
|
|
28
|
+
|
|
29
|
+
field :text_color, -> { String }, optional: false, nullable: false
|
|
30
|
+
|
|
31
|
+
field :title, -> { String }, optional: false, nullable: false
|
|
32
|
+
|
|
33
|
+
field :updated_at, -> { String }, optional: false, nullable: false
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Posters
|
|
5
|
+
module Types
|
|
6
|
+
class DeletePostersRequest < 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,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Posters
|
|
5
|
+
module Types
|
|
6
|
+
class GetPostersRequest < 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,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Posters
|
|
5
|
+
module Types
|
|
6
|
+
class GetPostersResponse < Internal::Types::Model
|
|
7
|
+
field :account_id, -> { Integer }, optional: false, nullable: false
|
|
8
|
+
|
|
9
|
+
field :active, -> { Internal::Types::Boolean }, optional: false, nullable: false
|
|
10
|
+
|
|
11
|
+
field :card_id, -> { Integer }, optional: false, nullable: false
|
|
12
|
+
|
|
13
|
+
field :created_at, -> { String }, optional: false, nullable: false
|
|
14
|
+
|
|
15
|
+
field :display_url, -> { String }, optional: false, nullable: false
|
|
16
|
+
|
|
17
|
+
field :id, -> { Integer }, optional: false, nullable: false
|
|
18
|
+
|
|
19
|
+
field :paper_size, -> { String }, optional: false, nullable: false
|
|
20
|
+
|
|
21
|
+
field :primary_color, -> { String }, optional: false, nullable: false
|
|
22
|
+
|
|
23
|
+
field :qr_code_url, -> { String }, optional: false, nullable: false
|
|
24
|
+
|
|
25
|
+
field :secondary_color, -> { String }, optional: false, nullable: false
|
|
26
|
+
|
|
27
|
+
field :signup_url, -> { String }, optional: false, nullable: false
|
|
28
|
+
|
|
29
|
+
field :text_color, -> { String }, optional: false, nullable: false
|
|
30
|
+
|
|
31
|
+
field :title, -> { String }, optional: false, nullable: false
|
|
32
|
+
|
|
33
|
+
field :updated_at, -> { String }, optional: false, nullable: false
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Posters
|
|
5
|
+
module Types
|
|
6
|
+
class ListPostersRequest < Internal::Types::Model
|
|
7
|
+
field :account_id, -> { Integer }, optional: false, nullable: false
|
|
8
|
+
|
|
9
|
+
field :card_id, -> { Integer }, optional: true, nullable: false
|
|
10
|
+
|
|
11
|
+
field :active, -> { String }, optional: true, nullable: false
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Posters
|
|
5
|
+
module Types
|
|
6
|
+
class ListPostersResponseItem < Internal::Types::Model
|
|
7
|
+
field :account_id, -> { Integer }, optional: false, nullable: false
|
|
8
|
+
|
|
9
|
+
field :active, -> { Internal::Types::Boolean }, optional: false, nullable: false
|
|
10
|
+
|
|
11
|
+
field :card_id, -> { Integer }, optional: false, nullable: false
|
|
12
|
+
|
|
13
|
+
field :created_at, -> { String }, optional: false, nullable: false
|
|
14
|
+
|
|
15
|
+
field :display_url, -> { String }, optional: false, nullable: false
|
|
16
|
+
|
|
17
|
+
field :id, -> { Integer }, optional: false, nullable: false
|
|
18
|
+
|
|
19
|
+
field :paper_size, -> { String }, optional: false, nullable: false
|
|
20
|
+
|
|
21
|
+
field :primary_color, -> { String }, optional: false, nullable: false
|
|
22
|
+
|
|
23
|
+
field :qr_code_url, -> { String }, optional: false, nullable: false
|
|
24
|
+
|
|
25
|
+
field :secondary_color, -> { String }, optional: false, nullable: false
|
|
26
|
+
|
|
27
|
+
field :signup_url, -> { String }, optional: false, nullable: false
|
|
28
|
+
|
|
29
|
+
field :text_color, -> { String }, optional: false, nullable: false
|
|
30
|
+
|
|
31
|
+
field :title, -> { String }, optional: false, nullable: false
|
|
32
|
+
|
|
33
|
+
field :updated_at, -> { String }, optional: false, nullable: false
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Posters
|
|
5
|
+
module Types
|
|
6
|
+
class UpdatePostersRequest < Internal::Types::Model
|
|
7
|
+
field :account_id, -> { Integer }, optional: false, nullable: false
|
|
8
|
+
|
|
9
|
+
field :id, -> { Integer }, optional: false, nullable: false
|
|
10
|
+
|
|
11
|
+
field :poster, -> { Leal::Posters::Types::UpdatePostersRequestPoster }, optional: false, nullable: false
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Posters
|
|
5
|
+
module Types
|
|
6
|
+
class UpdatePostersRequestPoster < Internal::Types::Model
|
|
7
|
+
field :active, -> { Internal::Types::Boolean }, optional: true, nullable: false
|
|
8
|
+
|
|
9
|
+
field :paper_size, -> { String }, optional: true, nullable: false
|
|
10
|
+
|
|
11
|
+
field :primary_color, -> { String }, optional: true, nullable: false
|
|
12
|
+
|
|
13
|
+
field :secondary_color, -> { String }, optional: true, nullable: false
|
|
14
|
+
|
|
15
|
+
field :text_color, -> { String }, optional: true, nullable: false
|
|
16
|
+
|
|
17
|
+
field :title, -> { String }, optional: true, nullable: false
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Posters
|
|
5
|
+
module Types
|
|
6
|
+
class UpdatePostersResponse < Internal::Types::Model
|
|
7
|
+
field :account_id, -> { Integer }, optional: false, nullable: false
|
|
8
|
+
|
|
9
|
+
field :active, -> { Internal::Types::Boolean }, optional: false, nullable: false
|
|
10
|
+
|
|
11
|
+
field :card_id, -> { Integer }, optional: false, nullable: false
|
|
12
|
+
|
|
13
|
+
field :created_at, -> { String }, optional: false, nullable: false
|
|
14
|
+
|
|
15
|
+
field :display_url, -> { String }, optional: false, nullable: false
|
|
16
|
+
|
|
17
|
+
field :id, -> { Integer }, optional: false, nullable: false
|
|
18
|
+
|
|
19
|
+
field :paper_size, -> { String }, optional: false, nullable: false
|
|
20
|
+
|
|
21
|
+
field :primary_color, -> { String }, optional: false, nullable: false
|
|
22
|
+
|
|
23
|
+
field :qr_code_url, -> { String }, optional: false, nullable: false
|
|
24
|
+
|
|
25
|
+
field :secondary_color, -> { String }, optional: false, nullable: false
|
|
26
|
+
|
|
27
|
+
field :signup_url, -> { String }, optional: false, nullable: false
|
|
28
|
+
|
|
29
|
+
field :text_color, -> { String }, optional: false, nullable: false
|
|
30
|
+
|
|
31
|
+
field :title, -> { String }, optional: false, nullable: false
|
|
32
|
+
|
|
33
|
+
field :updated_at, -> { String }, optional: false, nullable: false
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Rewards
|
|
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 rewards for the store. Optionally filter by card or active status.
|
|
14
|
+
#
|
|
15
|
+
# @param request_options [Hash]
|
|
16
|
+
# @param params [Hash]
|
|
17
|
+
# @option request_options [String] :base_url
|
|
18
|
+
# @option request_options [Hash{String => Object}] :additional_headers
|
|
19
|
+
# @option request_options [Hash{String => Object}] :additional_query_parameters
|
|
20
|
+
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
21
|
+
# @option request_options [Integer] :timeout_in_seconds
|
|
22
|
+
# @option params [Integer] :account_id
|
|
23
|
+
# @option params [Integer, nil] :card_id
|
|
24
|
+
# @option params [String, nil] :active
|
|
25
|
+
#
|
|
26
|
+
# @example
|
|
27
|
+
# client.rewards.list(account_id: 1)
|
|
28
|
+
#
|
|
29
|
+
# @return [Array[Leal::Rewards::Types::ListRewardsResponseItem]]
|
|
30
|
+
def list(request_options: {}, **params)
|
|
31
|
+
params = Leal::Internal::Types::Utils.normalize_keys(params)
|
|
32
|
+
query_params = {}
|
|
33
|
+
query_params["card_id"] = params[:card_id] if params.key?(:card_id)
|
|
34
|
+
query_params["active"] = params[:active] if params.key?(:active)
|
|
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)}/rewards",
|
|
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 reward for a loyalty card. The card must belong to the same store.
|
|
56
|
+
# The `card_id` is required on create but cannot be changed afterwards.
|
|
57
|
+
#
|
|
58
|
+
# @param request_options [Hash]
|
|
59
|
+
# @param params [Leal::Rewards::Types::CreateRewardsRequest]
|
|
60
|
+
# @option request_options [String] :base_url
|
|
61
|
+
# @option request_options [Hash{String => Object}] :additional_headers
|
|
62
|
+
# @option request_options [Hash{String => Object}] :additional_query_parameters
|
|
63
|
+
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
64
|
+
# @option request_options [Integer] :timeout_in_seconds
|
|
65
|
+
# @option params [Integer] :account_id
|
|
66
|
+
#
|
|
67
|
+
# @example
|
|
68
|
+
# client.rewards.create(
|
|
69
|
+
# account_id: 1,
|
|
70
|
+
# reward: {
|
|
71
|
+
# card_id: 1,
|
|
72
|
+
# name: "name",
|
|
73
|
+
# stamps_required: 1
|
|
74
|
+
# }
|
|
75
|
+
# )
|
|
76
|
+
#
|
|
77
|
+
# @return [Leal::Rewards::Types::CreateRewardsResponse]
|
|
78
|
+
def create(request_options: {}, **params)
|
|
79
|
+
params = Leal::Internal::Types::Utils.normalize_keys(params)
|
|
80
|
+
request_data = Leal::Rewards::Types::CreateRewardsRequest.new(params).to_h
|
|
81
|
+
non_body_param_names = %w[account_id]
|
|
82
|
+
body = request_data.except(*non_body_param_names)
|
|
83
|
+
|
|
84
|
+
request = Leal::Internal::JSON::Request.new(
|
|
85
|
+
base_url: request_options[:base_url],
|
|
86
|
+
method: "POST",
|
|
87
|
+
path: "api/v1/accounts/#{URI.encode_uri_component(params[:account_id].to_s)}/rewards",
|
|
88
|
+
body: body,
|
|
89
|
+
request_options: request_options
|
|
90
|
+
)
|
|
91
|
+
begin
|
|
92
|
+
response = @client.send(request)
|
|
93
|
+
rescue Net::HTTPRequestTimeout
|
|
94
|
+
raise Leal::Errors::TimeoutError
|
|
95
|
+
end
|
|
96
|
+
code = response.code.to_i
|
|
97
|
+
if code.between?(200, 299)
|
|
98
|
+
Leal::Rewards::Types::CreateRewardsResponse.load(response.body)
|
|
99
|
+
else
|
|
100
|
+
error_class = Leal::Errors::ResponseError.subclass_for_code(code)
|
|
101
|
+
raise error_class.new(response.body, code: code)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Returns a single reward by ID.
|
|
106
|
+
#
|
|
107
|
+
# @param request_options [Hash]
|
|
108
|
+
# @param params [Hash]
|
|
109
|
+
# @option request_options [String] :base_url
|
|
110
|
+
# @option request_options [Hash{String => Object}] :additional_headers
|
|
111
|
+
# @option request_options [Hash{String => Object}] :additional_query_parameters
|
|
112
|
+
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
113
|
+
# @option request_options [Integer] :timeout_in_seconds
|
|
114
|
+
# @option params [Integer] :account_id
|
|
115
|
+
# @option params [Integer] :id
|
|
116
|
+
#
|
|
117
|
+
# @example
|
|
118
|
+
# client.rewards.get(
|
|
119
|
+
# account_id: 1,
|
|
120
|
+
# id: 1
|
|
121
|
+
# )
|
|
122
|
+
#
|
|
123
|
+
# @return [Leal::Rewards::Types::GetRewardsResponse]
|
|
124
|
+
def get(request_options: {}, **params)
|
|
125
|
+
params = Leal::Internal::Types::Utils.normalize_keys(params)
|
|
126
|
+
request = Leal::Internal::JSON::Request.new(
|
|
127
|
+
base_url: request_options[:base_url],
|
|
128
|
+
method: "GET",
|
|
129
|
+
path: "api/v1/accounts/#{URI.encode_uri_component(params[:account_id].to_s)}/rewards/#{URI.encode_uri_component(params[:id].to_s)}",
|
|
130
|
+
request_options: request_options
|
|
131
|
+
)
|
|
132
|
+
begin
|
|
133
|
+
response = @client.send(request)
|
|
134
|
+
rescue Net::HTTPRequestTimeout
|
|
135
|
+
raise Leal::Errors::TimeoutError
|
|
136
|
+
end
|
|
137
|
+
code = response.code.to_i
|
|
138
|
+
if code.between?(200, 299)
|
|
139
|
+
Leal::Rewards::Types::GetRewardsResponse.load(response.body)
|
|
140
|
+
else
|
|
141
|
+
error_class = Leal::Errors::ResponseError.subclass_for_code(code)
|
|
142
|
+
raise error_class.new(response.body, code: code)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Permanently deletes a reward. This cannot be undone.
|
|
147
|
+
#
|
|
148
|
+
# @param request_options [Hash]
|
|
149
|
+
# @param params [Hash]
|
|
150
|
+
# @option request_options [String] :base_url
|
|
151
|
+
# @option request_options [Hash{String => Object}] :additional_headers
|
|
152
|
+
# @option request_options [Hash{String => Object}] :additional_query_parameters
|
|
153
|
+
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
154
|
+
# @option request_options [Integer] :timeout_in_seconds
|
|
155
|
+
# @option params [Integer] :account_id
|
|
156
|
+
# @option params [Integer] :id
|
|
157
|
+
#
|
|
158
|
+
# @example
|
|
159
|
+
# client.rewards.delete(
|
|
160
|
+
# account_id: 1,
|
|
161
|
+
# id: 1
|
|
162
|
+
# )
|
|
163
|
+
#
|
|
164
|
+
# @return [untyped]
|
|
165
|
+
def delete(request_options: {}, **params)
|
|
166
|
+
params = Leal::Internal::Types::Utils.normalize_keys(params)
|
|
167
|
+
request = Leal::Internal::JSON::Request.new(
|
|
168
|
+
base_url: request_options[:base_url],
|
|
169
|
+
method: "DELETE",
|
|
170
|
+
path: "api/v1/accounts/#{URI.encode_uri_component(params[:account_id].to_s)}/rewards/#{URI.encode_uri_component(params[:id].to_s)}",
|
|
171
|
+
request_options: request_options
|
|
172
|
+
)
|
|
173
|
+
begin
|
|
174
|
+
response = @client.send(request)
|
|
175
|
+
rescue Net::HTTPRequestTimeout
|
|
176
|
+
raise Leal::Errors::TimeoutError
|
|
177
|
+
end
|
|
178
|
+
code = response.code.to_i
|
|
179
|
+
return if code.between?(200, 299)
|
|
180
|
+
|
|
181
|
+
error_class = Leal::Errors::ResponseError.subclass_for_code(code)
|
|
182
|
+
raise error_class.new(response.body, code: code)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Updates an existing reward. The `card_id` cannot be changed after creation.
|
|
186
|
+
#
|
|
187
|
+
# @param request_options [Hash]
|
|
188
|
+
# @param params [Leal::Rewards::Types::UpdateRewardsRequest]
|
|
189
|
+
# @option request_options [String] :base_url
|
|
190
|
+
# @option request_options [Hash{String => Object}] :additional_headers
|
|
191
|
+
# @option request_options [Hash{String => Object}] :additional_query_parameters
|
|
192
|
+
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
193
|
+
# @option request_options [Integer] :timeout_in_seconds
|
|
194
|
+
# @option params [Integer] :account_id
|
|
195
|
+
# @option params [Integer] :id
|
|
196
|
+
#
|
|
197
|
+
# @example
|
|
198
|
+
# client.rewards.update(
|
|
199
|
+
# account_id: 1,
|
|
200
|
+
# id: 1,
|
|
201
|
+
# reward: {}
|
|
202
|
+
# )
|
|
203
|
+
#
|
|
204
|
+
# @return [Leal::Rewards::Types::UpdateRewardsResponse]
|
|
205
|
+
def update(request_options: {}, **params)
|
|
206
|
+
params = Leal::Internal::Types::Utils.normalize_keys(params)
|
|
207
|
+
request_data = Leal::Rewards::Types::UpdateRewardsRequest.new(params).to_h
|
|
208
|
+
non_body_param_names = %w[account_id id]
|
|
209
|
+
body = request_data.except(*non_body_param_names)
|
|
210
|
+
|
|
211
|
+
request = Leal::Internal::JSON::Request.new(
|
|
212
|
+
base_url: request_options[:base_url],
|
|
213
|
+
method: "PATCH",
|
|
214
|
+
path: "api/v1/accounts/#{URI.encode_uri_component(params[:account_id].to_s)}/rewards/#{URI.encode_uri_component(params[:id].to_s)}",
|
|
215
|
+
body: body,
|
|
216
|
+
request_options: request_options
|
|
217
|
+
)
|
|
218
|
+
begin
|
|
219
|
+
response = @client.send(request)
|
|
220
|
+
rescue Net::HTTPRequestTimeout
|
|
221
|
+
raise Leal::Errors::TimeoutError
|
|
222
|
+
end
|
|
223
|
+
code = response.code.to_i
|
|
224
|
+
if code.between?(200, 299)
|
|
225
|
+
Leal::Rewards::Types::UpdateRewardsResponse.load(response.body)
|
|
226
|
+
else
|
|
227
|
+
error_class = Leal::Errors::ResponseError.subclass_for_code(code)
|
|
228
|
+
raise error_class.new(response.body, code: code)
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Rewards
|
|
5
|
+
module Types
|
|
6
|
+
class CreateRewardsRequest < Internal::Types::Model
|
|
7
|
+
field :account_id, -> { Integer }, optional: false, nullable: false
|
|
8
|
+
|
|
9
|
+
field :reward, -> { Leal::Rewards::Types::CreateRewardsRequestReward }, optional: false, nullable: false
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Rewards
|
|
5
|
+
module Types
|
|
6
|
+
class CreateRewardsRequestReward < Internal::Types::Model
|
|
7
|
+
field :active, -> { Internal::Types::Boolean }, optional: true, nullable: false
|
|
8
|
+
|
|
9
|
+
field :card_id, -> { Integer }, optional: false, nullable: false
|
|
10
|
+
|
|
11
|
+
field :description, -> { String }, optional: true, nullable: false
|
|
12
|
+
|
|
13
|
+
field :name, -> { String }, optional: false, nullable: false
|
|
14
|
+
|
|
15
|
+
field :position, -> { Integer }, optional: true, nullable: false
|
|
16
|
+
|
|
17
|
+
field :stamps_required, -> { Integer }, optional: false, nullable: false
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Rewards
|
|
5
|
+
module Types
|
|
6
|
+
class CreateRewardsResponse < Internal::Types::Model
|
|
7
|
+
field :account_id, -> { Integer }, optional: false, nullable: false
|
|
8
|
+
|
|
9
|
+
field :active, -> { Internal::Types::Boolean }, optional: false, nullable: false
|
|
10
|
+
|
|
11
|
+
field :card_id, -> { Integer }, optional: false, nullable: false
|
|
12
|
+
|
|
13
|
+
field :created_at, -> { String }, optional: false, nullable: false
|
|
14
|
+
|
|
15
|
+
field :description, -> { String }, optional: false, nullable: false
|
|
16
|
+
|
|
17
|
+
field :id, -> { Integer }, optional: false, nullable: false
|
|
18
|
+
|
|
19
|
+
field :name, -> { String }, optional: false, nullable: false
|
|
20
|
+
|
|
21
|
+
field :position, -> { Integer }, optional: false, nullable: false
|
|
22
|
+
|
|
23
|
+
field :stamps_required, -> { Integer }, optional: false, nullable: false
|
|
24
|
+
|
|
25
|
+
field :updated_at, -> { String }, optional: false, nullable: false
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Rewards
|
|
5
|
+
module Types
|
|
6
|
+
class DeleteRewardsRequest < 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,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Rewards
|
|
5
|
+
module Types
|
|
6
|
+
class GetRewardsRequest < 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,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Rewards
|
|
5
|
+
module Types
|
|
6
|
+
class GetRewardsResponse < Internal::Types::Model
|
|
7
|
+
field :account_id, -> { Integer }, optional: false, nullable: false
|
|
8
|
+
|
|
9
|
+
field :active, -> { Internal::Types::Boolean }, optional: false, nullable: false
|
|
10
|
+
|
|
11
|
+
field :card_id, -> { Integer }, optional: false, nullable: false
|
|
12
|
+
|
|
13
|
+
field :created_at, -> { String }, optional: false, nullable: false
|
|
14
|
+
|
|
15
|
+
field :description, -> { String }, optional: false, nullable: false
|
|
16
|
+
|
|
17
|
+
field :id, -> { Integer }, optional: false, nullable: false
|
|
18
|
+
|
|
19
|
+
field :name, -> { String }, optional: false, nullable: false
|
|
20
|
+
|
|
21
|
+
field :position, -> { Integer }, optional: false, nullable: false
|
|
22
|
+
|
|
23
|
+
field :stamps_required, -> { Integer }, optional: false, nullable: false
|
|
24
|
+
|
|
25
|
+
field :updated_at, -> { String }, optional: false, nullable: false
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Rewards
|
|
5
|
+
module Types
|
|
6
|
+
class ListRewardsRequest < Internal::Types::Model
|
|
7
|
+
field :account_id, -> { Integer }, optional: false, nullable: false
|
|
8
|
+
|
|
9
|
+
field :card_id, -> { Integer }, optional: true, nullable: false
|
|
10
|
+
|
|
11
|
+
field :active, -> { String }, optional: true, nullable: false
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Rewards
|
|
5
|
+
module Types
|
|
6
|
+
class ListRewardsResponseItem < Internal::Types::Model
|
|
7
|
+
field :account_id, -> { Integer }, optional: false, nullable: false
|
|
8
|
+
|
|
9
|
+
field :active, -> { Internal::Types::Boolean }, optional: false, nullable: false
|
|
10
|
+
|
|
11
|
+
field :card_id, -> { Integer }, optional: false, nullable: false
|
|
12
|
+
|
|
13
|
+
field :created_at, -> { String }, optional: false, nullable: false
|
|
14
|
+
|
|
15
|
+
field :description, -> { String }, optional: false, nullable: false
|
|
16
|
+
|
|
17
|
+
field :id, -> { Integer }, optional: false, nullable: false
|
|
18
|
+
|
|
19
|
+
field :name, -> { String }, optional: false, nullable: false
|
|
20
|
+
|
|
21
|
+
field :position, -> { Integer }, optional: false, nullable: false
|
|
22
|
+
|
|
23
|
+
field :stamps_required, -> { Integer }, optional: false, nullable: false
|
|
24
|
+
|
|
25
|
+
field :updated_at, -> { String }, optional: false, nullable: false
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Leal
|
|
4
|
+
module Rewards
|
|
5
|
+
module Types
|
|
6
|
+
class UpdateRewardsRequest < Internal::Types::Model
|
|
7
|
+
field :account_id, -> { Integer }, optional: false, nullable: false
|
|
8
|
+
|
|
9
|
+
field :id, -> { Integer }, optional: false, nullable: false
|
|
10
|
+
|
|
11
|
+
field :reward, -> { Leal::Rewards::Types::UpdateRewardsRequestReward }, optional: false, nullable: false
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|