Class: NewStoreApi::ReasonCodesController

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

Overview

ReasonCodesController

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_reason_code(body, accept_language: 'en-US', feature: FeatureEnum::DISCOUNT) ⇒ void

This method returns an undefined value.

Creates a new reason code here reasons codes belong to.

Parameters:

  • body (ReasonCodeInit)

    Required parameter: TODO: type description

  • accept_language (String) (defaults to: 'en-US')

    Optional parameter: The locale that the

  • feature (FeatureEnum) (defaults to: FeatureEnum::DISCOUNT)

    Optional parameter: Example:DISCOUNT



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/new_store_api/controllers/reason_codes_controller.rb', line 37

def create_reason_code(body,
                       accept_language: 'en-US',
                       feature: FeatureEnum::DISCOUNT)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/promotions/reason-codes',
                                 Server::API)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter(accept_language, key: 'Accept-Language'))
               .query_param(new_parameter(feature, key: 'feature'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .is_response_void(true))
    .execute
end

#destroy_reason_code(code, accept_language: 'en-US', feature: FeatureEnum::DISCOUNT) ⇒ void

This method returns an undefined value.

Delete a reason code reason code.

Parameters:

  • code (String)

    Required parameter: An identifier of a reason code.

  • accept_language (String) (defaults to: 'en-US')

    Optional parameter: The locale of the

  • feature (FeatureEnum) (defaults to: FeatureEnum::DISCOUNT)

    Optional parameter: Example:DISCOUNT



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/new_store_api/controllers/reason_codes_controller.rb', line 61

def destroy_reason_code(code,
                        accept_language: 'en-US',
                        feature: FeatureEnum::DISCOUNT)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/promotions/reason-codes/{code}',
                                 Server::API)
               .template_param(new_parameter(code, key: 'code')
                                .should_encode(true))
               .header_param(new_parameter(accept_language, key: 'Accept-Language'))
               .query_param(new_parameter(feature, key: 'feature'))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .is_response_void(true))
    .execute
end

#list_reason_codes(accept_language: nil, feature: FeatureEnum::DISCOUNT) ⇒ ListResponse

Retrieves reason codes per locale codes. if not present all codes from all locales are returned.

Parameters:

  • accept_language (String) (defaults to: nil)

    Optional parameter: The locale of reason

  • feature (FeatureEnum) (defaults to: FeatureEnum::DISCOUNT)

    Optional parameter: Example:DISCOUNT

Returns:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/new_store_api/controllers/reason_codes_controller.rb', line 14

def list_reason_codes(accept_language: nil,
                      feature: FeatureEnum::DISCOUNT)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/promotions/reason-codes',
                                 Server::API)
               .header_param(new_parameter(accept_language, key: 'Accept-Language'))
               .query_param(new_parameter(feature, key: 'feature'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ListResponse.method(:from_hash)))
    .execute
end

#show_reason_code(code, feature: FeatureEnum::DISCOUNT) ⇒ GetResponse

Retrieves a reason code with all localisations

Parameters:

  • code (String)

    Required parameter: An identifier of a reason code.

  • feature (FeatureEnum) (defaults to: FeatureEnum::DISCOUNT)

    Optional parameter: Example:DISCOUNT

Returns:



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/new_store_api/controllers/reason_codes_controller.rb', line 82

def show_reason_code(code,
                     feature: FeatureEnum::DISCOUNT)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/promotions/reason-codes/{code}',
                                 Server::API)
               .template_param(new_parameter(code, key: 'code')
                                .should_encode(true))
               .query_param(new_parameter(feature, key: 'feature'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(GetResponse.method(:from_hash)))
    .execute
end

#update_reason_code(code, accept_language: 'en-US', feature: FeatureEnum::DISCOUNT, body: nil) ⇒ void

This method returns an undefined value.

Update the name of the reason code. reason code. here

Parameters:

  • code (String)

    Required parameter: An identifier of a reason code.

  • accept_language (String) (defaults to: 'en-US')

    Optional parameter: The locale of the

  • feature (FeatureEnum) (defaults to: FeatureEnum::DISCOUNT)

    Optional parameter: Example:DISCOUNT

  • body (ReasonCodePatch) (defaults to: nil)

    Optional parameter: TODO: type description



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/new_store_api/controllers/reason_codes_controller.rb', line 107

def update_reason_code(code,
                       accept_language: 'en-US',
                       feature: FeatureEnum::DISCOUNT,
                       body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/promotions/reason-codes/{code}',
                                 Server::API)
               .template_param(new_parameter(code, key: 'code')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(accept_language, key: 'Accept-Language'))
               .query_param(new_parameter(feature, key: 'feature'))
               .body_param(new_parameter(body))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .is_response_void(true))
    .execute
end