Skip to content

Adds support to Verify emails, fixes verify_delete method #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Addressing rubocop
  • Loading branch information
gabrielso committed Jun 25, 2021
commit 736c289009baf8c0da24d1347ae72bb23d890268
66 changes: 33 additions & 33 deletions examples/verify.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,39 @@
end

unless defined?(VERIFY_ID)
puts 'You need to set a VERIFY_ID constant in this file'
exit 1
end
puts 'You need to set a VERIFY_ID constant in this file'
exit 1
end

begin
# Create a MessageBird client with the specified ACCESS_KEY.
client = MessageBird::Client.new(ACCESS_KEY)

# Generate a new OTP message using an email as recipient
otp = client.verify(VERIFY_ID)

# Print the object information.
puts
puts 'The following information was returned as an OTP object:'
puts
puts " id : #{otp.id}"
puts " href : #{otp.href}"
puts " recipient : #{otp.recipient}"
puts " reference : #{otp.reference}"
puts " messages : #{otp.messages}"
puts " status : #{otp.status}"
puts " createdDatetime : #{otp.created_datetime}"
puts " validUntilDatetime : #{otp.valid_until_datetime}"
puts
rescue MessageBird::ErrorException => e
puts
puts 'An error occured while requesting an OTP object:'
# Create a MessageBird client with the specified ACCESS_KEY.
client = MessageBird::Client.new(ACCESS_KEY)

# Generate a new OTP message using an email as recipient
otp = client.verify(VERIFY_ID)

# Print the object information.
puts
puts 'The following information was returned as an OTP object:'
puts
puts " id : #{otp.id}"
puts " href : #{otp.href}"
puts " recipient : #{otp.recipient}"
puts " reference : #{otp.reference}"
puts " messages : #{otp.messages}"
puts " status : #{otp.status}"
puts " createdDatetime : #{otp.created_datetime}"
puts " validUntilDatetime : #{otp.valid_until_datetime}"
puts
rescue MessageBird::ErrorException => e
puts
puts 'An error occured while requesting an OTP object:'
puts

e.errors.each do |error|
puts " code : #{error.code}"
puts " description : #{error.description}"
puts " parameter : #{error.parameter}"
puts

e.errors.each do |error|
puts " code : #{error.code}"
puts " description : #{error.description}"
puts " parameter : #{error.parameter}"
puts
end
end
end
end
70 changes: 35 additions & 35 deletions examples/verify_create_email.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,39 @@
end

begin
# Create a MessageBird client with the specified ACCESS_KEY.
client = MessageBird::Client.new(ACCESS_KEY)

# Generate a new OTP message using an email as recipient
otp = client.verify_create('Recipient Name <[email protected]>', # RECIPIENT EMAIL HERE
originator: '[email protected]', # SENDER EMAIL HERE
type: 'email',
subject: 'Your Verify test token',
template: '%token - Use this code to validate your Verify token.',
reference: 'MessageBirdReference')

# Print the object information.
puts
puts 'The following information was returned as an OTP object:'
puts
puts " id : #{otp.id}"
puts " href : #{otp.href}"
puts " recipient : #{otp.recipient}"
puts " reference : #{otp.reference}"
puts " messages : #{otp.messages}"
puts " status : #{otp.status}"
puts " createdDatetime : #{otp.created_datetime}"
puts " validUntilDatetime : #{otp.valid_until_datetime}"
puts
rescue MessageBird::ErrorException => e
puts
puts 'An error occured while requesting an OTP object:'
# Create a MessageBird client with the specified ACCESS_KEY.
client = MessageBird::Client.new(ACCESS_KEY)

# Generate a new OTP message using an email as recipient
otp = client.verify_create('Recipient Name <[email protected]>', # RECIPIENT EMAIL HERE
originator: '[email protected]', # SENDER EMAIL HERE
type: 'email',
subject: 'Your Verify test token',
template: '%token - Use this code to validate your Verify token.',
reference: 'MessageBirdReference')

# Print the object information.
puts
puts 'The following information was returned as an OTP object:'
puts
puts " id : #{otp.id}"
puts " href : #{otp.href}"
puts " recipient : #{otp.recipient}"
puts " reference : #{otp.reference}"
puts " messages : #{otp.messages}"
puts " status : #{otp.status}"
puts " createdDatetime : #{otp.created_datetime}"
puts " validUntilDatetime : #{otp.valid_until_datetime}"
puts
rescue MessageBird::ErrorException => e
puts
puts 'An error occured while requesting an OTP object:'
puts

e.errors.each do |error|
puts " code : #{error.code}"
puts " description : #{error.description}"
puts " parameter : #{error.parameter}"
puts

e.errors.each do |error|
puts " code : #{error.code}"
puts " description : #{error.description}"
puts " parameter : #{error.parameter}"
puts
end
end
end
end
48 changes: 24 additions & 24 deletions examples/verify_delete.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@
end

unless defined?(VERIFY_ID)
puts 'You need to set a VERIFY_ID constant in this file'
exit 1
end
puts 'You need to set a VERIFY_ID constant in this file'
exit 1
end

begin
# Create a MessageBird client with the specified ACCESS_KEY.
client = MessageBird::Client.new(ACCESS_KEY)

# Delete the verify
client.verify_delete(VERIFY_ID)

# Print the object information.
puts
puts 'Success. The delete method has empty return.'
puts
rescue MessageBird::ErrorException => e
puts
puts 'An error occured while requesting an OTP object:'
# Create a MessageBird client with the specified ACCESS_KEY.
client = MessageBird::Client.new(ACCESS_KEY)

# Delete the verify
client.verify_delete(VERIFY_ID)

# Print the object information.
puts
puts 'Success. The delete method has empty return.'
puts
rescue MessageBird::ErrorException => e
puts
puts 'An error occured while requesting an OTP object:'
puts

e.errors.each do |error|
puts " code : #{error.code}"
puts " description : #{error.description}"
puts " parameter : #{error.parameter}"
puts

e.errors.each do |error|
puts " code : #{error.code}"
puts " description : #{error.description}"
puts " parameter : #{error.parameter}"
puts
end
end
end
end
54 changes: 27 additions & 27 deletions examples/verify_email_message.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@
end

unless defined?(MESSAGE_ID)
puts 'You need to set a MESSAGE_ID constant in this file'
exit 1
end
puts 'You need to set a MESSAGE_ID constant in this file'
exit 1
end

begin
# Create a MessageBird client with the specified ACCESS_KEY.
client = MessageBird::Client.new(ACCESS_KEY)

# Generate a new OTP message using an email as recipient
verify_message = client.verify_email_message(MESSAGE_ID)

# Print the object information.
puts
puts 'The following information was returned as Verify Email Message object:'
puts
puts " id : #{verify_message.id}"
puts " status : #{verify_message.status}"
puts
rescue MessageBird::ErrorException => e
puts
puts 'An error occured while requesting an OTP object:'
# Create a MessageBird client with the specified ACCESS_KEY.
client = MessageBird::Client.new(ACCESS_KEY)

# Generate a new OTP message using an email as recipient
verify_message = client.verify_email_message(MESSAGE_ID)

# Print the object information.
puts
puts 'The following information was returned as Verify Email Message object:'
puts
puts " id : #{verify_message.id}"
puts " status : #{verify_message.status}"
puts
rescue MessageBird::ErrorException => e
puts
puts 'An error occured while requesting an OTP object:'
puts

e.errors.each do |error|
puts " code : #{error.code}"
puts " description : #{error.description}"
puts " parameter : #{error.parameter}"
puts

e.errors.each do |error|
puts " code : #{error.code}"
puts " description : #{error.description}"
puts " parameter : #{error.parameter}"
puts
end
end
end
end