MessageMedia Signature Key Management Ruby SDK

Build Status Gem Version

The MessageMedia Signature Key API provides a number of endpoints for managing key used to sign each unique request to ensure security and the requests can't (easily) be spoofed. This is similar to using HMAC in your outbound messaging (rather than HTTP Basic).

⭐️ Install via RubyGems

  • Run the following command to install the SDK via RubyGems: gem install messagemedia_signingkeys_sdk

🎬 Get Started

It's easy to get started. Simply enter the API Key and secret you obtained from the MessageMedia Developers Portal into the code snippet below and a mobile number you wish to send to.

🚀 Create a signature key

require 'message_media_signing_keys'
require 'pp'

# Configuration parameters and credentials
basic_auth_user_name = 'basic_auth_user_name' # The username to use with basic authentication
basic_auth_password = 'basic_auth_password' # The password to use with basic authentication

client = MessageMediaSigningKeys::MessageMediaSigningKeysClient.new(
  basic_auth_user_name: basic_auth_user_name,
  basic_auth_password: basic_auth_password
)

signatureKeyManagement_controller = client.signature_key_management

body_value = "{   
                \"digest\": \"SHA224\",   
                \"cipher\": \"RSA\"
}";
body = JSON.parse(body_value);

result = signatureKeyManagement_controller.create_signature_key(body)
pp result

📥 Get signature key details

You can get a key_id by looking at the id of the signature key created from the response of the above example.

require 'message_media_signing_keys'
require 'pp'

# Configuration parameters and credentials
basic_auth_user_name = 'basic_auth_user_name' # The username to use with basic authentication
basic_auth_password = 'basic_auth_password' # The password to use with basic authentication

client = MessageMediaSigningKeys::MessageMediaSigningKeysClient.new(
  basic_auth_user_name: basic_auth_user_name,
  basic_auth_password: basic_auth_password
)

signatureKeyManagement_controller = client.signature_key_management

key_id = 'key_id'

result = signatureKeyManagement_controller.get_signature_key_detail(key_id)
pp result

📥 Get signature keys list

require 'message_media_signing_keys'
require 'pp'

# Configuration parameters and credentials
basic_auth_user_name = 'basic_auth_user_name' # The username to use with basic authentication
basic_auth_password = 'basic_auth_password' # The password to use with basic authentication

client = MessageMediaSigningKeys::MessageMediaSigningKeysClient.new(
  basic_auth_user_name: basic_auth_user_name,
  basic_auth_password: basic_auth_password
)

signatureKeyManagement_controller = client.signature_key_management

result = signatureKeyManagement_controller.get_signature_key_list()
pp result

❌ Delete signature key

You can get the key_id by looking at the ids of the signature keys returned from the response of the Get signature keys list example.

require 'message_media_signing_keys'

# Configuration parameters and credentials
basic_auth_user_name = 'basic_auth_user_name' # The username to use with basic authentication
basic_auth_password = 'basic_auth_password' # The password to use with basic authentication

client = MessageMediaSigningKeys::MessageMediaSigningKeysClient.new(
  basic_auth_user_name: basic_auth_user_name,
  basic_auth_password: basic_auth_password
)

signatureKeyManagement_controller = client.signature_key_management

key_id = 'key_id'

signatureKeyManagement_controller.delete_signature_key(key_id)

☑️ Enable a signature key

You can get the key_id by looking at the ids of the signature keys returned from the response of the Get signature keys list example.

require 'message_media_signing_keys'
require 'pp'

# Configuration parameters and credentials
basic_auth_user_name = 'basic_auth_user_name' # The username to use with basic authentication
basic_auth_password = 'basic_auth_password' # The password to use with basic authentication

client = MessageMediaSigningKeys::MessageMediaSigningKeysClient.new(
  basic_auth_user_name: basic_auth_user_name,
  basic_auth_password: basic_auth_password
)

signatureKeyManagement_controller = client.signature_key_management

body = EnableSignatureKeyRequest.new({
    "key_id": "7ca628a8-08b0-4e42-aeb8-960b37049c31"
})

result = signatureKeyManagement_controller.update_enable_signature_key(body)
pp result

📥 Get enabled signature key

require 'message_media_signing_keys'
require 'pp'

# Configuration parameters and credentials
basic_auth_user_name = 'basic_auth_user_name' # The username to use with basic authentication
basic_auth_password = 'basic_auth_password' # The password to use with basic authentication

client = MessageMediaSigningKeys::MessageMediaSigningKeysClient.new(
  basic_auth_user_name: basic_auth_user_name,
  basic_auth_password: basic_auth_password
)

signatureKeyManagement_controller = client.signature_key_management

result = signatureKeyManagement_controller.get_enabled_signature_key()
pp result

🚫 Disable an enabled signature key

require 'message_media_signing_keys'

# Configuration parameters and credentials
basic_auth_user_name = 'basic_auth_user_name' # The username to use with basic authentication
basic_auth_password = 'basic_auth_password' # The password to use with basic authentication

client = MessageMediaSigningKeys::MessageMediaSigningKeysClient.new(
  basic_auth_user_name: basic_auth_user_name,
  basic_auth_password: basic_auth_password
)

signatureKeyManagement_controller = client.signature_key_management

signatureKeyManagement_controller.delete_disable_the_current_enabled_signature_key()

📕 Documentation

Check out the full API documentation for more detailed information.

😕 Need help?

Please contact developer support at [email protected] or check out the developer portal at developers.messagemedia.com

📃 License

Apache License. See the LICENSE file.