Class: AliyunIntelligentCaptcha::Client

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

Constant Summary collapse

ACTION =
"VerifyIntelligentCaptcha"
CONTENT_TYPE =
"application/json; charset=utf-8"
SIGNATURE_ALGORITHM =
"ACS3-HMAC-SHA256"

Instance Method Summary collapse

Constructor Details

#initialize(access_key_id:, access_key_secret:, endpoint: Configuration::DEFAULT_ENDPOINT, api_version: Configuration::DEFAULT_API_VERSION, scene_id: nil, open_timeout: Configuration::DEFAULT_OPEN_TIMEOUT, read_timeout: Configuration::DEFAULT_READ_TIMEOUT, logger: nil, http_client: nil) ⇒ Client

Returns a new instance of Client.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/aliyun_intelligent_captcha/client.rb', line 21

def initialize(access_key_id:,
               access_key_secret:,
               endpoint: Configuration::DEFAULT_ENDPOINT,
               api_version: Configuration::DEFAULT_API_VERSION,
               scene_id: nil,
               open_timeout: Configuration::DEFAULT_OPEN_TIMEOUT,
               read_timeout: Configuration::DEFAULT_READ_TIMEOUT,
               logger: nil,
               http_client: nil)
  @access_key_id = access_key_id
  @access_key_secret = access_key_secret
  @endpoint = endpoint
  @api_version = api_version
  @scene_id = scene_id
  @open_timeout = open_timeout
  @read_timeout = read_timeout
  @logger = logger
  @http_client = http_client
end

Instance Method Details

#verify(captcha_verify_param:, scene_id: @scene_id, **extra) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/aliyun_intelligent_captcha/client.rb', line 41

def verify(captcha_verify_param:, scene_id: @scene_id, **extra)
  ensure_configured!

  payload = normalize_payload(
    extra.merge(captcha_verify_param: captcha_verify_param, scene_id: scene_id).compact
  )
  response = perform_request(payload)
  Result.new(body: parse_response(response.body), status: response.code)
end