Module: AliyunDypns
- Defined in:
- lib/aliyun_dypns.rb,
lib/aliyun_dypns/version.rb
Defined Under Namespace
Classes: Configuration
Constant Summary collapse
- VERSION =
"0.1.1"
Class Attribute Summary collapse
Class Method Summary collapse
- .client ⇒ Object
- .configure {|configuration| ... } ⇒ Object
-
.get_mobile(access_token, out_id = "") ⇒ Object
{ “Message”: “请求成功”, “RequestId”: 8906582, “Code”: “OK”, “GetMobileResultDTO”: { “Mobile”: 121343241 } }.
-
.verify_mobile(access_code, phone_number, out_id = "") ⇒ Object
{ “GateVerifyResultDTO”: { “VerifyResult”: “PASS”, “VerifyId”: 121343241 }, “Message”: “请求成功”, “RequestId”: 8906582, “Code”: “OK” } PASS:一致。 REJECT:不一致。 UNKNOWN:无法判断。.
Class Attribute Details
.configuration ⇒ Object
27 28 29 |
# File 'lib/aliyun_dypns.rb', line 27 def configuration @configuration ||= Configuration.new end |
Class Method Details
.client ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/aliyun_dypns.rb', line 82 def client @client ||= RPCClient.new( access_key_id: configuration.access_key_id, access_key_secret: configuration.access_key_secret, api_version: configuration.api_version, endpoint: "https://dypnsapi.aliyuncs.com", ) end |
.configure {|configuration| ... } ⇒ Object
31 32 33 |
# File 'lib/aliyun_dypns.rb', line 31 def configure yield(configuration) end |
.get_mobile(access_token, out_id = "") ⇒ Object
{
"Message": "请求成功",
"RequestId": 8906582,
"Code": "OK",
"GetMobileResultDTO": {
"Mobile": 121343241
}
}
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/aliyun_dypns.rb', line 44 def get_mobile(access_token, out_id = "") response = client.request( action: "GetMobile", params: { "RegionId": configuration.region_id, "AccessToken": access_token, "OutId": out_id, }, opts: { method: "POST" }, ) response.dig("GetMobileResultDTO", "Mobile") end |
.verify_mobile(access_code, phone_number, out_id = "") ⇒ Object
{
"GateVerifyResultDTO": {
"VerifyResult": "PASS",
"VerifyId": 121343241
},
"Message": "请求成功",
"RequestId": 8906582,
"Code": "OK"
} PASS:一致。 REJECT:不一致。 UNKNOWN:无法判断。
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/aliyun_dypns.rb', line 67 def verify_mobile(access_code, phone_number, out_id = "") response = client.request( action: "VerifyMobile", params: { "RegionId": configuration.region_id, "AccessCode": access_code, "PhoneNumber": phone_number, "OutId": out_id, }, opts: { method: "POST" }, ) response.dig("GateVerifyResultDTO", "VerifyResult") end |