Class: Schematic::Scheduledcheckout::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/schematic/scheduledcheckout/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



9
10
11
# File 'lib/schematic/scheduledcheckout/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#create_scheduled_checkout(request_options: {}, **params) ⇒ Schematic::Scheduledcheckout::Types::CreateScheduledCheckoutResponse

Examples:

client.scheduledcheckout.create_scheduled_checkout(
  company_id: "company_id",
  execute_after: "2024-01-15T09:30:00Z",
  from_plan_id: "from_plan_id",
  to_plan_id: "to_plan_id"
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/schematic/scheduledcheckout/client.rb', line 80

def create_scheduled_checkout(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "scheduled-checkout",
    body: Schematic::Scheduledcheckout::Types::CreateScheduledCheckoutRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Schematic::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Schematic::Scheduledcheckout::Types::CreateScheduledCheckoutResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_scheduled_checkout(request_options: {}, **params) ⇒ Schematic::Scheduledcheckout::Types::GetScheduledCheckoutResponse

Examples:

client.scheduledcheckout.get_scheduled_checkout(scheduled_checkout_id: "scheduled_checkout_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :scheduled_checkout_id (String)

Returns:



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/schematic/scheduledcheckout/client.rb', line 116

def get_scheduled_checkout(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "scheduled-checkout/#{URI.encode_uri_component(params[:scheduled_checkout_id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Schematic::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Schematic::Scheduledcheckout::Types::GetScheduledCheckoutResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_scheduled_checkouts(request_options: {}, **params) ⇒ Schematic::Scheduledcheckout::Types::ListScheduledCheckoutsResponse

Examples:

client.scheduledcheckout.list_scheduled_checkouts(
  company_id: "company_id",
  status: "cancelled",
  limit: 1000000,
  offset: 1000000
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/schematic/scheduledcheckout/client.rb', line 34

def list_scheduled_checkouts(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["company_id"] = params[:company_id] if params.key?(:company_id)
  query_params["status"] = params[:status] if params.key?(:status)
  query_params["limit"] = params[:limit] if params.key?(:limit)
  query_params["offset"] = params[:offset] if params.key?(:offset)

  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "scheduled-checkout",
    query: query_params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Schematic::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Schematic::Scheduledcheckout::Types::ListScheduledCheckoutsResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#update_scheduled_checkout(request_options: {}, **params) ⇒ Schematic::Scheduledcheckout::Types::UpdateScheduledCheckoutResponse

Examples:

client.scheduledcheckout.update_scheduled_checkout(scheduled_checkout_id: "scheduled_checkout_id")

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :scheduled_checkout_id (String)

Returns:



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/schematic/scheduledcheckout/client.rb', line 151

def update_scheduled_checkout(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  request_data = Schematic::Scheduledcheckout::Types::UpdateScheduledCheckoutRequest.new(params).to_h
  non_body_param_names = %w[scheduled_checkout_id]
  body = request_data.except(*non_body_param_names)

  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PUT",
    path: "scheduled-checkout/#{URI.encode_uri_component(params[:scheduled_checkout_id].to_s)}",
    body: body,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Schematic::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Schematic::Scheduledcheckout::Types::UpdateScheduledCheckoutResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end