Class: Tencent::Cloud::SmsApi

Inherits:
Client
  • Object
show all
Defined in:
lib/tencent/cloud/sms_api.rb

Instance Attribute Summary

Attributes inherited from Client

#host, #options, #region, #schema, #secret_id, #secret_key, #service

Instance Method Summary collapse

Methods inherited from Client

#algorithm, #authorization, #camel_case, #canonical_headers, #connection, #credential_scope, #hash_sha256, #hashed_canonical_request, #hashed_request_payload, #hex_encode, #hmac_sha256, #json, #method_missing, #post, #public_headers, #respond_to_missing?, #secret_signing, #sign_date, #sign_time, #sign_timestamp, #sign_version, #signature, #signed_headers, #string_to_sign, #switch_to

Constructor Details

#initialize(*args) ⇒ SmsApi

Returns a new instance of SmsApi.



5
6
7
8
# File 'lib/tencent/cloud/sms_api.rb', line 5

def initialize(*args)
  super(*args)
  switch_to('sms', 'sms.tencentcloudapi.com')
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Tencent::Cloud::Client

Instance Method Details

#describe_sms_sign_list(list, international) ⇒ Object



28
29
30
31
32
# File 'lib/tencent/cloud/sms_api.rb', line 28

def describe_sms_sign_list(list, international)
  headers = { Action: 'DescribeSmsSignList' }.merge(share_headers)
  datus = { SignIdSet: list, International: international }
  post(datus, headers)
end

#send_sms(numbers, template_id, params, sign = nil, **args) ⇒ Object

Send SMS to client

Parameters:

  • numbers (Array)

    client numbers in format +[country_code]

  • template_id (String)

    sms template id

  • params (Array)

    sms template params

  • sign (String) (defaults to: nil)

    optional for china local message

  • args (Hash)

    other api parameters



18
19
20
21
22
23
24
25
26
# File 'lib/tencent/cloud/sms_api.rb', line 18

def send_sms(numbers, template_id, params, sign = nil, **args)
  headers = { Action: 'SendSms' }.merge(share_headers)
  datus = {
    PhoneNumberSet: numbers, TemplateID: template_id,
    Sign: sign, TemplateParamSet: params
  }
  datus.merge!(args) if args
  post(datus, headers)
end

#share_headersObject



34
35
36
# File 'lib/tencent/cloud/sms_api.rb', line 34

def share_headers
  { Version: '2019-07-11', SmsSdkAppid: options[:SmsSdkAppid].to_s }
end