Class: NewStoreApi::ClientsController

Inherits:
BaseController show all
Defined in:
lib/new_store_api/controllers/clients_controller.rb

Overview

ClientsController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent

Constructor Details

This class inherits a constructor from NewStoreApi::BaseController

Instance Method Details

#create_client(body) ⇒ PostClientResponse

Creates a new API client for the tenant.

Parameters:

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/new_store_api/controllers/clients_controller.rb', line 27

def create_client(body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/iam/clients',
                                 Server::API)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PostClientResponse.method(:from_hash)))
    .execute
end

#destroy_client(id) ⇒ void

This method returns an undefined value.

🚧 BETA: This endpoint is in beta and may change.
See API Lifecycle Documentation for details.
Deletes the clients identified by its id

Parameters:

  • id (String)

    Required parameter: client id



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/new_store_api/controllers/clients_controller.rb', line 55

def destroy_client(id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/iam/clients/{id}',
                                 Server::API)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .is_response_void(true))
    .execute
end

#list_clientsGetClientsResponse

Returns a list of api clients for the tenant

Returns:



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/new_store_api/controllers/clients_controller.rb', line 11

def list_clients
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/iam/clients',
                                 Server::API)
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(GetClientsResponse.method(:from_hash)))
    .execute
end

#list_scopesGetScopesResponse

🚧 BETA: This endpoint is in beta and may change.
See API Lifecycle Documentation for details.
Returns a list of supported API scopes

Returns:



97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/new_store_api/controllers/clients_controller.rb', line 97

def list_scopes
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/iam/scopes',
                                 Server::API)
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(GetScopesResponse.method(:from_hash)))
    .execute
end

#show_client(id) ⇒ GetClientResponse

Returns the client identified by its id

Parameters:

  • id (String)

    Required parameter: client id

Returns:



71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/new_store_api/controllers/clients_controller.rb', line 71

def show_client(id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/iam/clients/{id}',
                                 Server::API)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(GetClientResponse.method(:from_hash)))
    .execute
end