Module: NotificationService::Sms::Alibaba::APIConfig

Included in:
Authentication, Service
Defined in:
app/services/notification_service/sms/alibaba/api_config.rb

Instance Method Summary collapse

Instance Method Details

#access_key_secretObject



25
26
27
# File 'app/services/notification_service/sms/alibaba/api_config.rb', line 25

def access_key_secret
  Figaro.env.ALIBABA_ACCESS_KEY_SECRET!
end

#default_paramsObject



7
8
9
10
11
12
13
14
15
# File 'app/services/notification_service/sms/alibaba/api_config.rb', line 7

def default_params
  {
    AccessKeyId: Figaro.env.ALIBABA_ACCESS_KEY_ID!,
    Format: 'JSON',
    SignatureMethod: 'HMAC-SHA1',
    SignatureVersion: '1.0',
    Version: AdminSetting.alibaba_sms_api_version,
  }
end

#endpointObject



3
4
5
# File 'app/services/notification_service/sms/alibaba/api_config.rb', line 3

def endpoint
  AdminSetting.alibaba_sms_api_host
end

#http_methodObject



21
22
23
# File 'app/services/notification_service/sms/alibaba/api_config.rb', line 21

def http_method
  'GET'
end

#separatorObject



17
18
19
# File 'app/services/notification_service/sms/alibaba/api_config.rb', line 17

def separator
  '&'
end

#sort_params(params, sort = 'asc') ⇒ Hash

Sorts the given parameters in ascending or descending order based on the specified sort order (default asc).

Parameters:

  • params (Hash)

    The parameters to be sorted.

  • sort (String) (defaults to: 'asc')

    The sort order. Valid values are 'asc' for ascending and 'desc' for descending.

Returns:

  • (Hash)

    The sorted parameters.

Raises:

  • (ArgumentError)

    If the params argument is not a hash or if the sort argument is not 'asc' or 'desc'.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/services/notification_service/sms/alibaba/api_config.rb', line 35

def sort_params(params, sort = 'asc')
  unless params.is_a?(Hash)
    raise ArgumentError, "Params must be a hash, got #{params.class} instead."
  end

  case sort.downcase
  when 'asc'
    params.sort.to_h
  when 'desc'
    params.sort.reverse.to_h
  else
    raise ArgumentError, "Invalid sort order: #{sort}. Use 'asc' or 'desc'."
  end
end