module Rop
通道编码: open.rongcapital.cn/dashboard/isv/SmsBalanceList API调用Doc: open.rongcapital.cn/welcome/document/1109a17a-5873-420e-a590-c4ce6c5a2d59
Constants
- API_BASE
- VERSION
Attributes
access_token[RW]
channel_code[RW]
Public Class Methods
get_balance()
click to toggle source
# File lib/rop.rb, line 36 def self.get_balance post('ruixue.sms.balance.get', { channel_code: Rop.channel_code }) end
post(method, body = {})
click to toggle source
# File lib/rop.rb, line 20 def self.post(method, body = {}) begin body.merge!({ method: method, channel_code: Rop.channel_code, access_token: Rop.access_token, format: 'json' }) query = URI.encode_www_form(body) res = HTTParty.post("#{API_BASE}?#{query}", verify: false, body: body.to_json) return JSON.parse(res.body) rescue JSON::ParserError raise Sendcloud::Error.new('rop response invalid') end end
send_sms(mobile, content, append_code)
click to toggle source
# File lib/rop.rb, line 42 def self.send_sms(mobile, content, append_code) post("ruixue.sms.note.send", { mobile: mobile, content: content, append_code: append_code }) end
setup() { |self| ... }
click to toggle source
# File lib/rop.rb, line 12 def self.setup yield self end