class MagicBell::Client
Public Class Methods
new(api_key: nil, api_secret: nil)
click to toggle source
# File lib/magicbell/client.rb, line 12 def initialize(api_key: nil, api_secret: nil) @api_key = api_key @api_secret = api_secret end
Public Instance Methods
authentication_headers()
click to toggle source
# File lib/magicbell/client.rb, line 30 def authentication_headers MagicBell.authentication_headers(client_api_key: @api_key, client_api_secret: @api_secret) end
create_notification(notification_attributes)
click to toggle source
# File lib/magicbell/client.rb, line 17 def create_notification(notification_attributes) MagicBell::Notification.create(self, notification_attributes) end
hmac(message)
click to toggle source
# File lib/magicbell/client.rb, line 34 def hmac(message) secret = @api_secret || MagicBell.api_secret Base64.encode64(OpenSSL::HMAC::digest(sha256_digest, secret, message)).strip end
user_with_email(email)
click to toggle source
def user(user_id)
MagicBell::User.find(user_id)
end
# File lib/magicbell/client.rb, line 25 def user_with_email(email) client = self MagicBell::User.new(client, "email" => email) end
Private Instance Methods
sha256_digest()
click to toggle source
# File lib/magicbell/client.rb, line 42 def sha256_digest OpenSSL::Digest::Digest.new('sha256') end