Class: Sendly::VerifyResource
- Inherits:
-
Object
- Object
- Sendly::VerifyResource
- Defined in:
- lib/sendly/verify.rb
Instance Attribute Summary collapse
-
#sessions ⇒ Object
readonly
Returns the value of attribute sessions.
Instance Method Summary collapse
- #check(id, code:) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(client) ⇒ VerifyResource
constructor
A new instance of VerifyResource.
- #list(limit: nil, status: nil) ⇒ Object
- #resend(id) ⇒ Object
- #send(to:, template_id: nil, profile_id: nil, app_name: nil, timeout_secs: nil, code_length: nil) ⇒ Object
Constructor Details
#initialize(client) ⇒ VerifyResource
Returns a new instance of VerifyResource.
165 166 167 168 |
# File 'lib/sendly/verify.rb', line 165 def initialize(client) @client = client @sessions = SessionsResource.new(client) end |
Instance Attribute Details
#sessions ⇒ Object (readonly)
Returns the value of attribute sessions.
163 164 165 |
# File 'lib/sendly/verify.rb', line 163 def sessions @sessions end |
Instance Method Details
#check(id, code:) ⇒ Object
188 189 190 191 |
# File 'lib/sendly/verify.rb', line 188 def check(id, code:) response = @client.post("/verify/#{id}/check", { code: code }) CheckVerificationResponse.new(response) end |
#get(id) ⇒ Object
193 194 195 196 |
# File 'lib/sendly/verify.rb', line 193 def get(id) response = @client.get("/verify/#{id}") Verification.new(response) end |
#list(limit: nil, status: nil) ⇒ Object
198 199 200 201 202 203 204 205 206 |
# File 'lib/sendly/verify.rb', line 198 def list(limit: nil, status: nil) params = {} params[:limit] = limit if limit params[:status] = status if status response = @client.get("/verify", params) verifications = (response["verifications"] || []).map { |v| Verification.new(v) } { verifications: verifications, pagination: response["pagination"] } end |
#resend(id) ⇒ Object
183 184 185 186 |
# File 'lib/sendly/verify.rb', line 183 def resend(id) response = @client.post("/verify/#{id}/resend") SendVerificationResponse.new(response) end |
#send(to:, template_id: nil, profile_id: nil, app_name: nil, timeout_secs: nil, code_length: nil) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/sendly/verify.rb', line 170 def send(to:, template_id: nil, profile_id: nil, app_name: nil, timeout_secs: nil, code_length: nil) body = { to: to } body[:template_id] = template_id if template_id body[:profile_id] = profile_id if profile_id body[:app_name] = app_name if app_name body[:timeout_secs] = timeout_secs if timeout_secs body[:code_length] = code_length if code_length response = @client.post("/verify", body) SendVerificationResponse.new(response) end |