terminal-shop 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +27 -19
  3. data/lib/terminal-shop/base_client.rb +2 -0
  4. data/lib/terminal-shop/base_model.rb +471 -440
  5. data/lib/terminal-shop/base_page.rb +20 -0
  6. data/lib/terminal-shop/models/cart.rb +35 -2
  7. data/lib/terminal-shop/models/cart_convert_params.rb +11 -1
  8. data/lib/terminal-shop/models/cart_redeem_gift_card_params.rb +24 -0
  9. data/lib/terminal-shop/models/cart_redeem_gift_card_response.rb +48 -0
  10. data/lib/terminal-shop/models/cart_remove_gift_card_params.rb +18 -0
  11. data/lib/terminal-shop/models/cart_remove_gift_card_response.rb +19 -0
  12. data/lib/terminal-shop/models/product.rb +11 -6
  13. data/lib/terminal-shop/pooled_net_requester.rb +23 -10
  14. data/lib/terminal-shop/resources/cart.rb +43 -1
  15. data/lib/terminal-shop/util.rb +146 -52
  16. data/lib/terminal-shop/version.rb +1 -1
  17. data/lib/terminal-shop.rb +4 -0
  18. data/rbi/lib/terminal-shop/base_client.rbi +23 -21
  19. data/rbi/lib/terminal-shop/base_model.rbi +235 -217
  20. data/rbi/lib/terminal-shop/client.rbi +2 -2
  21. data/rbi/lib/terminal-shop/errors.rbi +8 -8
  22. data/rbi/lib/terminal-shop/models/address.rbi +2 -2
  23. data/rbi/lib/terminal-shop/models/address_create_params.rbi +3 -13
  24. data/rbi/lib/terminal-shop/models/address_create_response.rbi +2 -2
  25. data/rbi/lib/terminal-shop/models/address_delete_params.rbi +5 -2
  26. data/rbi/lib/terminal-shop/models/address_delete_response.rbi +2 -2
  27. data/rbi/lib/terminal-shop/models/address_get_params.rbi +5 -2
  28. data/rbi/lib/terminal-shop/models/address_get_response.rbi +2 -2
  29. data/rbi/lib/terminal-shop/models/address_list_params.rbi +5 -2
  30. data/rbi/lib/terminal-shop/models/address_list_response.rbi +2 -2
  31. data/rbi/lib/terminal-shop/models/app.rbi +2 -2
  32. data/rbi/lib/terminal-shop/models/app_create_params.rbi +2 -2
  33. data/rbi/lib/terminal-shop/models/app_create_response.rbi +4 -4
  34. data/rbi/lib/terminal-shop/models/app_delete_params.rbi +5 -2
  35. data/rbi/lib/terminal-shop/models/app_delete_response.rbi +2 -2
  36. data/rbi/lib/terminal-shop/models/app_get_params.rbi +5 -2
  37. data/rbi/lib/terminal-shop/models/app_get_response.rbi +2 -2
  38. data/rbi/lib/terminal-shop/models/app_list_params.rbi +5 -2
  39. data/rbi/lib/terminal-shop/models/app_list_response.rbi +2 -2
  40. data/rbi/lib/terminal-shop/models/card.rbi +4 -4
  41. data/rbi/lib/terminal-shop/models/card_collect_params.rbi +5 -2
  42. data/rbi/lib/terminal-shop/models/card_collect_response.rbi +4 -4
  43. data/rbi/lib/terminal-shop/models/card_create_params.rbi +2 -2
  44. data/rbi/lib/terminal-shop/models/card_create_response.rbi +2 -2
  45. data/rbi/lib/terminal-shop/models/card_delete_params.rbi +5 -2
  46. data/rbi/lib/terminal-shop/models/card_delete_response.rbi +2 -2
  47. data/rbi/lib/terminal-shop/models/card_get_params.rbi +5 -2
  48. data/rbi/lib/terminal-shop/models/card_get_response.rbi +2 -2
  49. data/rbi/lib/terminal-shop/models/card_list_params.rbi +5 -2
  50. data/rbi/lib/terminal-shop/models/card_list_response.rbi +2 -2
  51. data/rbi/lib/terminal-shop/models/cart.rbi +45 -9
  52. data/rbi/lib/terminal-shop/models/cart_convert_params.rbi +17 -3
  53. data/rbi/lib/terminal-shop/models/cart_convert_response.rbi +2 -2
  54. data/rbi/lib/terminal-shop/models/cart_get_params.rbi +5 -2
  55. data/rbi/lib/terminal-shop/models/cart_get_response.rbi +2 -2
  56. data/rbi/lib/terminal-shop/models/cart_redeem_gift_card_params.rbi +32 -0
  57. data/rbi/lib/terminal-shop/models/cart_redeem_gift_card_response.rbi +66 -0
  58. data/rbi/lib/terminal-shop/models/cart_remove_gift_card_params.rbi +21 -0
  59. data/rbi/lib/terminal-shop/models/cart_remove_gift_card_response.rbi +23 -0
  60. data/rbi/lib/terminal-shop/models/cart_set_address_params.rbi +2 -2
  61. data/rbi/lib/terminal-shop/models/cart_set_address_response.rbi +2 -2
  62. data/rbi/lib/terminal-shop/models/cart_set_card_params.rbi +2 -2
  63. data/rbi/lib/terminal-shop/models/cart_set_card_response.rbi +2 -2
  64. data/rbi/lib/terminal-shop/models/cart_set_item_params.rbi +2 -2
  65. data/rbi/lib/terminal-shop/models/cart_set_item_response.rbi +2 -2
  66. data/rbi/lib/terminal-shop/models/email_create_params.rbi +2 -2
  67. data/rbi/lib/terminal-shop/models/email_create_response.rbi +2 -2
  68. data/rbi/lib/terminal-shop/models/order.rbi +10 -10
  69. data/rbi/lib/terminal-shop/models/order_create_params.rbi +2 -2
  70. data/rbi/lib/terminal-shop/models/order_create_response.rbi +2 -2
  71. data/rbi/lib/terminal-shop/models/order_get_params.rbi +5 -2
  72. data/rbi/lib/terminal-shop/models/order_get_response.rbi +2 -2
  73. data/rbi/lib/terminal-shop/models/order_list_params.rbi +5 -2
  74. data/rbi/lib/terminal-shop/models/order_list_response.rbi +2 -2
  75. data/rbi/lib/terminal-shop/models/product.rbi +29 -14
  76. data/rbi/lib/terminal-shop/models/product_get_params.rbi +5 -2
  77. data/rbi/lib/terminal-shop/models/product_get_response.rbi +2 -2
  78. data/rbi/lib/terminal-shop/models/product_list_params.rbi +5 -2
  79. data/rbi/lib/terminal-shop/models/product_list_response.rbi +2 -2
  80. data/rbi/lib/terminal-shop/models/product_variant.rbi +2 -2
  81. data/rbi/lib/terminal-shop/models/profile.rbi +4 -4
  82. data/rbi/lib/terminal-shop/models/profile_me_params.rbi +5 -2
  83. data/rbi/lib/terminal-shop/models/profile_me_response.rbi +2 -2
  84. data/rbi/lib/terminal-shop/models/profile_update_params.rbi +2 -2
  85. data/rbi/lib/terminal-shop/models/profile_update_response.rbi +2 -2
  86. data/rbi/lib/terminal-shop/models/subscription.rbi +15 -13
  87. data/rbi/lib/terminal-shop/models/subscription_create_params.rbi +5 -2
  88. data/rbi/lib/terminal-shop/models/subscription_create_response.rbi +2 -2
  89. data/rbi/lib/terminal-shop/models/subscription_delete_params.rbi +5 -2
  90. data/rbi/lib/terminal-shop/models/subscription_delete_response.rbi +2 -2
  91. data/rbi/lib/terminal-shop/models/subscription_get_params.rbi +5 -2
  92. data/rbi/lib/terminal-shop/models/subscription_get_response.rbi +2 -2
  93. data/rbi/lib/terminal-shop/models/subscription_list_params.rbi +5 -2
  94. data/rbi/lib/terminal-shop/models/subscription_list_response.rbi +2 -2
  95. data/rbi/lib/terminal-shop/models/token.rbi +2 -2
  96. data/rbi/lib/terminal-shop/models/token_create_params.rbi +5 -2
  97. data/rbi/lib/terminal-shop/models/token_create_response.rbi +4 -4
  98. data/rbi/lib/terminal-shop/models/token_delete_params.rbi +5 -2
  99. data/rbi/lib/terminal-shop/models/token_delete_response.rbi +2 -2
  100. data/rbi/lib/terminal-shop/models/token_get_params.rbi +5 -2
  101. data/rbi/lib/terminal-shop/models/token_get_response.rbi +2 -2
  102. data/rbi/lib/terminal-shop/models/token_list_params.rbi +5 -2
  103. data/rbi/lib/terminal-shop/models/token_list_response.rbi +2 -2
  104. data/rbi/lib/terminal-shop/models/view_init_params.rbi +5 -2
  105. data/rbi/lib/terminal-shop/models/view_init_response.rbi +5 -15
  106. data/rbi/lib/terminal-shop/pooled_net_requester.rbi +15 -10
  107. data/rbi/lib/terminal-shop/request_options.rbi +4 -0
  108. data/rbi/lib/terminal-shop/resources/address.rbi +2 -2
  109. data/rbi/lib/terminal-shop/resources/app.rbi +2 -2
  110. data/rbi/lib/terminal-shop/resources/card.rbi +2 -2
  111. data/rbi/lib/terminal-shop/resources/cart.rbi +24 -4
  112. data/rbi/lib/terminal-shop/resources/email.rbi +2 -2
  113. data/rbi/lib/terminal-shop/resources/order.rbi +2 -2
  114. data/rbi/lib/terminal-shop/resources/product.rbi +2 -2
  115. data/rbi/lib/terminal-shop/resources/profile.rbi +2 -2
  116. data/rbi/lib/terminal-shop/resources/subscription.rbi +2 -2
  117. data/rbi/lib/terminal-shop/resources/token.rbi +2 -2
  118. data/rbi/lib/terminal-shop/resources/view.rbi +2 -2
  119. data/rbi/lib/terminal-shop/util.rbi +181 -126
  120. data/rbi/lib/terminal-shop/version.rbi +1 -1
  121. data/sig/terminal-shop/models/cart.rbs +27 -2
  122. data/sig/terminal-shop/models/cart_convert_params.rbs +10 -2
  123. data/sig/terminal-shop/models/cart_redeem_gift_card_params.rbs +25 -0
  124. data/sig/terminal-shop/models/cart_redeem_gift_card_response.rbs +47 -0
  125. data/sig/terminal-shop/models/cart_remove_gift_card_params.rbs +19 -0
  126. data/sig/terminal-shop/models/cart_remove_gift_card_response.rbs +18 -0
  127. data/sig/terminal-shop/models/product.rbs +8 -2
  128. data/sig/terminal-shop/pooled_net_requester.rbs +4 -2
  129. data/sig/terminal-shop/request_options.rbs +4 -0
  130. data/sig/terminal-shop/resources/cart.rbs +20 -0
  131. data/sig/terminal-shop/util.rbs +27 -2
  132. data/sig/terminal-shop/version.rbs +1 -1
  133. metadata +14 -2
@@ -5,6 +5,26 @@ module TerminalShop
5
5
  #
6
6
  # @abstract
7
7
  #
8
+ # @example
9
+ # ```ruby
10
+ # if page.has_next?
11
+ # page = page.next_page
12
+ # end
13
+ # ```
14
+ #
15
+ # @example
16
+ # ```ruby
17
+ # page.auto_paging_each do |product|
18
+ # puts(product)
19
+ # end
20
+ # ```
21
+ #
22
+ # @example
23
+ # ```ruby
24
+ # products = page.to_enum.take(2)
25
+ #
26
+ # products => Array
27
+ # ```
8
28
  module BasePage
9
29
  # @return [Boolean]
10
30
  #
@@ -41,6 +41,16 @@ module TerminalShop
41
41
  # # @return [String]
42
42
  # attr_writer :card_id
43
43
 
44
+ # @!attribute [r] gift_card_id
45
+ # ID of the gift card applied to the current user's cart.
46
+ #
47
+ # @return [String, nil]
48
+ optional :gift_card_id, String, api_name: :giftCardID
49
+
50
+ # @!parse
51
+ # # @return [String]
52
+ # attr_writer :gift_card_id
53
+
44
54
  # @!attribute [r] shipping
45
55
  # Shipping information for the current user's cart.
46
56
  #
@@ -59,9 +69,10 @@ module TerminalShop
59
69
  # # @param subtotal [Integer]
60
70
  # # @param address_id [String]
61
71
  # # @param card_id [String]
72
+ # # @param gift_card_id [String]
62
73
  # # @param shipping [TerminalShop::Models::CartAPI::Shipping]
63
74
  # #
64
- # def initialize(amount:, items:, subtotal:, address_id: nil, card_id: nil, shipping: nil, **) = super
75
+ # def initialize(amount:, items:, subtotal:, address_id: nil, card_id: nil, gift_card_id: nil, shipping: nil, **) = super
65
76
 
66
77
  # def initialize: (Hash | TerminalShop::BaseModel) -> void
67
78
 
@@ -72,6 +83,16 @@ module TerminalShop
72
83
  # @return [Integer]
73
84
  required :subtotal, Integer
74
85
 
86
+ # @!attribute [r] gift_card
87
+ # Amount applied from gift card on the current user's cart, in cents (USD).
88
+ #
89
+ # @return [Integer, nil]
90
+ optional :gift_card, Integer, api_name: :giftCard
91
+
92
+ # @!parse
93
+ # # @return [Integer]
94
+ # attr_writer :gift_card
95
+
75
96
  # @!attribute [r] shipping
76
97
  # Shipping amount of the current user's cart, in cents (USD).
77
98
  #
@@ -82,13 +103,25 @@ module TerminalShop
82
103
  # # @return [Integer]
83
104
  # attr_writer :shipping
84
105
 
106
+ # @!attribute [r] total
107
+ # Total amount after gift card applied, in cents (USD).
108
+ #
109
+ # @return [Integer, nil]
110
+ optional :total, Integer
111
+
112
+ # @!parse
113
+ # # @return [Integer]
114
+ # attr_writer :total
115
+
85
116
  # @!parse
86
117
  # # The subtotal and shipping amounts for the current user's cart.
87
118
  # #
88
119
  # # @param subtotal [Integer]
120
+ # # @param gift_card [Integer]
89
121
  # # @param shipping [Integer]
122
+ # # @param total [Integer]
90
123
  # #
91
- # def initialize(subtotal:, shipping: nil, **) = super
124
+ # def initialize(subtotal:, gift_card: nil, shipping: nil, total: nil, **) = super
92
125
 
93
126
  # def initialize: (Hash | TerminalShop::BaseModel) -> void
94
127
  end
@@ -7,10 +7,20 @@ module TerminalShop
7
7
  # extend TerminalShop::RequestParameters::Converter
8
8
  include TerminalShop::RequestParameters
9
9
 
10
+ # @!attribute [r] recipient_email
11
+ #
12
+ # @return [String, nil]
13
+ optional :recipient_email, String, api_name: :recipientEmail
14
+
15
+ # @!parse
16
+ # # @return [String]
17
+ # attr_writer :recipient_email
18
+
10
19
  # @!parse
20
+ # # @param recipient_email [String]
11
21
  # # @param request_options [TerminalShop::RequestOptions, Hash{Symbol=>Object}]
12
22
  # #
13
- # def initialize(request_options: {}, **) = super
23
+ # def initialize(recipient_email: nil, request_options: {}, **) = super
14
24
 
15
25
  # def initialize: (Hash | TerminalShop::BaseModel) -> void
16
26
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TerminalShop
4
+ module Models
5
+ class CartRedeemGiftCardParams < TerminalShop::BaseModel
6
+ # @!parse
7
+ # extend TerminalShop::RequestParameters::Converter
8
+ include TerminalShop::RequestParameters
9
+
10
+ # @!attribute gift_card_id
11
+ #
12
+ # @return [String]
13
+ required :gift_card_id, String, api_name: :giftCardID
14
+
15
+ # @!parse
16
+ # # @param gift_card_id [String]
17
+ # # @param request_options [TerminalShop::RequestOptions, Hash{Symbol=>Object}]
18
+ # #
19
+ # def initialize(gift_card_id:, request_options: {}, **) = super
20
+
21
+ # def initialize: (Hash | TerminalShop::BaseModel) -> void
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TerminalShop
4
+ module Models
5
+ class CartRedeemGiftCardResponse < TerminalShop::BaseModel
6
+ # @!attribute data
7
+ # Gift card redemption result
8
+ #
9
+ # @return [TerminalShop::Models::CartRedeemGiftCardResponse::Data]
10
+ required :data, -> { TerminalShop::Models::CartRedeemGiftCardResponse::Data }
11
+
12
+ # @!parse
13
+ # # @param data [TerminalShop::Models::CartRedeemGiftCardResponse::Data]
14
+ # #
15
+ # def initialize(data:, **) = super
16
+
17
+ # def initialize: (Hash | TerminalShop::BaseModel) -> void
18
+
19
+ class Data < TerminalShop::BaseModel
20
+ # @!attribute applied_amount
21
+ #
22
+ # @return [Integer]
23
+ required :applied_amount, Integer, api_name: :appliedAmount
24
+
25
+ # @!attribute gift_card_id
26
+ #
27
+ # @return [String]
28
+ required :gift_card_id, String, api_name: :giftCardID
29
+
30
+ # @!attribute remaining_balance
31
+ #
32
+ # @return [Integer]
33
+ required :remaining_balance, Integer, api_name: :remainingBalance
34
+
35
+ # @!parse
36
+ # # Gift card redemption result
37
+ # #
38
+ # # @param applied_amount [Integer]
39
+ # # @param gift_card_id [String]
40
+ # # @param remaining_balance [Integer]
41
+ # #
42
+ # def initialize(applied_amount:, gift_card_id:, remaining_balance:, **) = super
43
+
44
+ # def initialize: (Hash | TerminalShop::BaseModel) -> void
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TerminalShop
4
+ module Models
5
+ class CartRemoveGiftCardParams < TerminalShop::BaseModel
6
+ # @!parse
7
+ # extend TerminalShop::RequestParameters::Converter
8
+ include TerminalShop::RequestParameters
9
+
10
+ # @!parse
11
+ # # @param request_options [TerminalShop::RequestOptions, Hash{Symbol=>Object}]
12
+ # #
13
+ # def initialize(request_options: {}, **) = super
14
+
15
+ # def initialize: (Hash | TerminalShop::BaseModel) -> void
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TerminalShop
4
+ module Models
5
+ class CartRemoveGiftCardResponse < TerminalShop::BaseModel
6
+ # @!attribute data
7
+ #
8
+ # @return [Symbol, :ok]
9
+ required :data, const: :ok
10
+
11
+ # @!parse
12
+ # # @param data [Symbol, :ok]
13
+ # #
14
+ # def initialize(data: :ok, **) = super
15
+
16
+ # def initialize: (Hash | TerminalShop::BaseModel) -> void
17
+ end
18
+ end
19
+ end
@@ -80,11 +80,6 @@ module TerminalShop
80
80
  REQUIRED = :required
81
81
 
82
82
  finalize!
83
-
84
- # @!parse
85
- # # @return [Array<Symbol>]
86
- # #
87
- # def self.values; end
88
83
  end
89
84
 
90
85
  class Tags < TerminalShop::BaseModel
@@ -133,6 +128,15 @@ module TerminalShop
133
128
  # # @return [Boolean]
134
129
  # attr_writer :market_na
135
130
 
131
+ # @!attribute [r] type
132
+ #
133
+ # @return [String, nil]
134
+ optional :type, String
135
+
136
+ # @!parse
137
+ # # @return [String]
138
+ # attr_writer :type
139
+
136
140
  # @!parse
137
141
  # # Tags for the product.
138
142
  # #
@@ -141,8 +145,9 @@ module TerminalShop
141
145
  # # @param featured [Boolean]
142
146
  # # @param market_eu [Boolean]
143
147
  # # @param market_na [Boolean]
148
+ # # @param type [String]
144
149
  # #
145
- # def initialize(app: nil, color: nil, featured: nil, market_eu: nil, market_na: nil, **) = super
150
+ # def initialize(app: nil, color: nil, featured: nil, market_eu: nil, market_na: nil, type: nil, **) = super
146
151
 
147
152
  # def initialize: (Hash | TerminalShop::BaseModel) -> void
148
153
  end
@@ -48,9 +48,11 @@ module TerminalShop
48
48
  #
49
49
  # @option request [Hash{String=>String}] :headers
50
50
  #
51
+ # @param blk [Proc]
52
+ #
51
53
  # @return [Net::HTTPGenericRequest]
52
54
  #
53
- def build_request(request)
55
+ def build_request(request, &)
54
56
  method, url, headers, body = request.fetch_values(:method, :url, :headers, :body)
55
57
  req = Net::HTTPGenericRequest.new(
56
58
  method.to_s.upcase,
@@ -64,12 +66,14 @@ module TerminalShop
64
66
  case body
65
67
  in nil
66
68
  in String
67
- req.body = body
69
+ req["content-length"] ||= body.bytesize.to_s unless req["transfer-encoding"]
70
+ req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &)
68
71
  in StringIO
69
- req.body = body.string
70
- in IO
71
- body.rewind
72
- req.body_stream = body
72
+ req["content-length"] ||= body.size.to_s unless req["transfer-encoding"]
73
+ req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &)
74
+ in IO | Enumerator
75
+ req["transfer-encoding"] ||= "chunked" unless req["content-length"]
76
+ req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &)
73
77
  end
74
78
 
75
79
  req
@@ -97,7 +101,7 @@ module TerminalShop
97
101
 
98
102
  pool =
99
103
  @mutex.synchronize do
100
- @pools[origin] ||= ConnectionPool.new(size: Etc.nprocessors) do
104
+ @pools[origin] ||= ConnectionPool.new(size: @size) do
101
105
  self.class.connect(url)
102
106
  end
103
107
  end
@@ -128,7 +132,6 @@ module TerminalShop
128
132
  #
129
133
  def execute(request)
130
134
  url, deadline = request.fetch_values(:url, :deadline)
131
- req = self.class.build_request(request)
132
135
 
133
136
  eof = false
134
137
  finished = false
@@ -136,6 +139,10 @@ module TerminalShop
136
139
  with_pool(url) do |conn|
137
140
  next if finished
138
141
 
142
+ req = self.class.build_request(request) do
143
+ self.class.calibrate_socket_timeout(conn, deadline)
144
+ end
145
+
139
146
  self.class.calibrate_socket_timeout(conn, deadline)
140
147
  conn.start unless conn.started?
141
148
 
@@ -156,19 +163,25 @@ module TerminalShop
156
163
  end
157
164
 
158
165
  conn, response = enum.next
159
- body = TerminalShop::Util.fused_enum(enum) do
166
+ body = TerminalShop::Util.fused_enum(enum, external: true) do
160
167
  finished = true
161
168
  tap do
162
169
  enum.next
163
170
  rescue StopIteration
171
+ nil
164
172
  end
165
173
  conn.finish if !eof && conn&.started?
166
174
  end
167
175
  [response, (response.body = body)]
168
176
  end
169
177
 
170
- def initialize
178
+ # @private
179
+ #
180
+ # @param size [Integer]
181
+ #
182
+ def initialize(size: Etc.nprocessors)
171
183
  @mutex = Mutex.new
184
+ @size = size
172
185
  @pools = {}
173
186
  end
174
187
  end
@@ -7,16 +7,20 @@ module TerminalShop
7
7
  #
8
8
  # @param params [TerminalShop::Models::CartConvertParams, Hash{Symbol=>Object}] .
9
9
  #
10
+ # @option params [String] :recipient_email
11
+ #
10
12
  # @option params [TerminalShop::RequestOptions, Hash{Symbol=>Object}, nil] :request_options
11
13
  #
12
14
  # @return [TerminalShop::Models::CartConvertResponse]
13
15
  #
14
16
  def convert(params = {})
17
+ parsed, options = TerminalShop::Models::CartConvertParams.dump_request(params)
15
18
  @client.request(
16
19
  method: :post,
17
20
  path: "cart/convert",
21
+ body: parsed,
18
22
  model: TerminalShop::Models::CartConvertResponse,
19
- options: params[:request_options]
23
+ options: options
20
24
  )
21
25
  end
22
26
 
@@ -37,6 +41,44 @@ module TerminalShop
37
41
  )
38
42
  end
39
43
 
44
+ # Apply a gift card to the current user's cart.
45
+ #
46
+ # @param params [TerminalShop::Models::CartRedeemGiftCardParams, Hash{Symbol=>Object}] .
47
+ #
48
+ # @option params [String] :gift_card_id
49
+ #
50
+ # @option params [TerminalShop::RequestOptions, Hash{Symbol=>Object}, nil] :request_options
51
+ #
52
+ # @return [TerminalShop::Models::CartRedeemGiftCardResponse]
53
+ #
54
+ def redeem_gift_card(params)
55
+ parsed, options = TerminalShop::Models::CartRedeemGiftCardParams.dump_request(params)
56
+ @client.request(
57
+ method: :put,
58
+ path: "cart/gift-card",
59
+ body: parsed,
60
+ model: TerminalShop::Models::CartRedeemGiftCardResponse,
61
+ options: options
62
+ )
63
+ end
64
+
65
+ # Remove the gift card from the current user's cart.
66
+ #
67
+ # @param params [TerminalShop::Models::CartRemoveGiftCardParams, Hash{Symbol=>Object}] .
68
+ #
69
+ # @option params [TerminalShop::RequestOptions, Hash{Symbol=>Object}, nil] :request_options
70
+ #
71
+ # @return [TerminalShop::Models::CartRemoveGiftCardResponse]
72
+ #
73
+ def remove_gift_card(params = {})
74
+ @client.request(
75
+ method: :delete,
76
+ path: "cart/gift-card",
77
+ model: TerminalShop::Models::CartRemoveGiftCardResponse,
78
+ options: params[:request_options]
79
+ )
80
+ end
81
+
40
82
  # Set the shipping address for the current user's cart.
41
83
  #
42
84
  # @param params [TerminalShop::Models::CartSetAddressParams, Hash{Symbol=>Object}] .