smooch-ruby
SmoochApi - the Ruby gem for the Smooch API
The Smooch API is a unified interface for powering messaging in your customer experiences across every channel. Our API speeds access to new markets, reduces time to ship, eliminates complexity, and helps you build the best experiences for your customers. For more information, visit our official documentation.
This SDK is automatically generated by the Swagger Codegen project using the Smooch api spec.
Smooch API Version
The Smooch API offers multiple versions. Each release of this project targets one and only one Smooch API version. If you depend on an older version of the Smooch API, you may need to use an older release of this library. Use the table below as your guide:
Smooch API version | smooch-ruby version to use |
---|---|
v1.1 Upgrade guide |
4.0.0 or newer |
v1 |
3.* or older |
Installation
Install the gem:
gem install smooch-api
Add this to the Gemfile:
gem 'smooch-api', '~> 4.2.0'
Getting Started
Authentication with JSON Web Tokens (JWTs)
JSON Web Tokens (JWTs) are an industry standard authentication mechanism. A great introduction to the technology is available here, and a broad set of supported JWT libraries for a variety of languages and platforms are available.
A JWT is composed of a header, a payload, and a signature. The payload contains information called claims which describe the subject to whom the token was issued.
Before you can make calls to the Smooch API, you'll need to create a JWT that proves you are authorized to use the API.
Step 1 Generate a KEY ID and SECRET on the settings tab in the Smooch Dashboard.
#### Step 2 Generate the JWT
Using the ruby-jwt gem:
require 'jwt'
payload = {:scope => 'app'}
jwtHeader = {:kid => KEY_ID}
token = JWT.encode payload, SECRET, 'HS256', jwtHeader
Running the code
# Load the gem
require 'smooch-api'
# Setup authorization
SmoochApi.configure do |config|
# Configure API key authorization: jwt
config.api_key['Authorization'] = 'YOUR JWT'
config.api_key_prefix['Authorization'] = 'Bearer'
end
api_instance = SmoochApi::AppApi.new
appCreateBody = SmoochApi::AppCreate.new # AppCreate | Body for a createApp request.
begin
result = api_instance.create_app(appCreateBody)
p result
rescue SmoochApi::ApiError => e
puts "Exception when calling AppApi->create_app: #{e}"
end
Region
Smooch is available in the following regions. The US region will be used by default. To target any other region, specify the region API host in config.host
. For example:
SmoochApi.configure do |config|
config.api_key['Authorization'] = '<jwt>'
config.api_key_prefix['Authorization'] = 'Bearer'
config.host = 'api.eu-1.smooch.io'
end
Documentation for API Endpoints
All URIs are relative to https://api.smooch.io
Class | Method | HTTP request | Description |
---|---|---|---|
SmoochApi::AppApi | create_app | POST /v1.1/apps | |
SmoochApi::AppApi | create_secret_key | POST /v1.1/apps/appId/keys | |
SmoochApi::AppApi | delete_app | DELETE /v1.1/apps/appId | |
SmoochApi::AppApi | delete_secret_key | DELETE /v1.1/apps/appId/keys/keyId | |
SmoochApi::AppApi | get_app | GET /v1.1/apps/appId | |
SmoochApi::AppApi | get_app_jwt | GET /v1.1/apps/appId/keys/keyId/jwt | |
SmoochApi::AppApi | get_secret_key | GET /v1.1/apps/appId/keys/keyId | |
SmoochApi::AppApi | list_apps | GET /v1.1/apps | |
SmoochApi::AppApi | list_secret_keys | GET /v1.1/apps/appId/keys | |
SmoochApi::AppApi | update_app | PUT /v1.1/apps/appId | |
SmoochApi::AppUserApi | delete_app_user | DELETE /v1.1/apps/appId/appusers/userId | |
SmoochApi::AppUserApi | delete_app_user_profile | DELETE /v1.1/apps/appId/appusers/userId/profile | |
SmoochApi::AppUserApi | get_app_user | GET /v1.1/apps/appId/appusers/userId | |
SmoochApi::AppUserApi | get_app_user_auth_code | GET /v1.1/apps/appId/appusers/userId/authcode | |
SmoochApi::AppUserApi | get_app_user_business_system_ids | GET /v1.1/apps/appId/appusers/userId/businesssystems | |
SmoochApi::AppUserApi | get_app_user_entity_ids | GET /v1.1/apps/appId/appusers/userId/channels | |
SmoochApi::AppUserApi | get_link_requests | GET /v1.1/apps/appId/appusers/userId/linkrequest | |
SmoochApi::AppUserApi | link_app_user | POST /v1.1/apps/appId/appusers/userId/channels | |
SmoochApi::AppUserApi | post_image_message | POST /v1.1/apps/appId/appusers/userId/images | |
SmoochApi::AppUserApi | pre_create_app_user | POST /v1.1/apps/appId/appusers | |
SmoochApi::AppUserApi | unlink_app_user | DELETE /v1.1/apps/appId/appusers/userId/channels/channel | |
SmoochApi::AppUserApi | update_app_user | PUT /v1.1/apps/appId/appusers/userId | |
SmoochApi::AttachmentsApi | remove_attachment | POST /v1.1/apps/appId/attachments/remove | |
SmoochApi::AttachmentsApi | upload_attachment | POST /v1.1/apps/appId/attachments | |
SmoochApi::ConversationApi | delete_message | DELETE /v1.1/apps/appId/appusers/userId/messages/messageId | |
SmoochApi::ConversationApi | delete_messages | DELETE /v1.1/apps/appId/appusers/userId/messages | |
SmoochApi::ConversationApi | get_messages | GET /v1.1/apps/appId/appusers/userId/messages | |
SmoochApi::ConversationApi | post_message | POST /v1.1/apps/appId/appusers/userId/messages | |
SmoochApi::ConversationApi | reset_unread_count | POST /v1.1/apps/appId/appusers/userId/conversation/read | |
SmoochApi::ConversationApi | trigger_typing_activity | POST /v1.1/apps/appId/appusers/userId/conversation/activity | |
SmoochApi::IntegrationApi | create_integration | POST /v1.1/apps/appId/integrations | |
SmoochApi::IntegrationApi | create_integration_menu | POST /v1.1/apps/appId/integrations/integrationId/menu | |
SmoochApi::IntegrationApi | delete_integration | DELETE /v1.1/apps/appId/integrations/integrationId | |
SmoochApi::IntegrationApi | delete_integration_menu | DELETE /v1.1/apps/appId/integrations/integrationId/menu | |
SmoochApi::IntegrationApi | get_integration | GET /v1.1/apps/appId/integrations/integrationId | |
SmoochApi::IntegrationApi | get_integration_menu | GET /v1.1/apps/appId/integrations/integrationId/menu | |
SmoochApi::IntegrationApi | list_integrations | GET /v1.1/apps/appId/integrations | |
SmoochApi::IntegrationApi | update_integration | PUT /v1.1/apps/appId/integrations/integrationId | |
SmoochApi::IntegrationApi | update_integration_menu | PUT /v1.1/apps/appId/integrations/integrationId/menu | |
SmoochApi::IntegrationApi | update_integration_profile | PUT /v1.1/apps/appId/integrations/integrationId/profile | |
SmoochApi::MenuApi | delete_menu | DELETE /v1.1/apps/appId/menu | |
SmoochApi::MenuApi | get_menu | GET /v1.1/apps/appId/menu | |
SmoochApi::MenuApi | update_menu | PUT /v1.1/apps/appId/menu | |
SmoochApi::ServiceAccountApi | create_secret_key | POST /v1.1/serviceaccounts/serviceAccountId/keys | |
SmoochApi::ServiceAccountApi | create_service_account | POST /v1.1/serviceaccounts | |
SmoochApi::ServiceAccountApi | delete_secret_key | DELETE /v1.1/serviceaccounts/serviceAccountId/keys/keyId | |
SmoochApi::ServiceAccountApi | delete_service_account | DELETE /v1.1/serviceaccounts/serviceAccountId | |
SmoochApi::ServiceAccountApi | get_jwt | GET /v1.1/serviceaccounts/serviceAccountId/keys/keyId/jwt | |
SmoochApi::ServiceAccountApi | get_secret_key | GET /v1.1/serviceaccounts/serviceAccountId/keys/keyId | |
SmoochApi::ServiceAccountApi | get_service_account | GET /v1.1/serviceaccounts/serviceAccountId | |
SmoochApi::ServiceAccountApi | list_secret_keys | GET /v1.1/serviceaccounts/serviceAccountId/keys | |
SmoochApi::ServiceAccountApi | list_service_accounts | GET /v1.1/serviceaccounts | |
SmoochApi::ServiceAccountApi | update_service_account | PUT /v1.1/serviceaccounts/serviceAccountId | |
SmoochApi::TemplateApi | create_template | POST /v1.1/apps/appId/templates | |
SmoochApi::TemplateApi | delete_template | DELETE /v1.1/apps/appId/templates/templateId | |
SmoochApi::TemplateApi | get_template | GET /v1.1/apps/appId/templates/templateId | |
SmoochApi::TemplateApi | list_templates | GET /v1.1/apps/appId/templates | |
SmoochApi::TemplateApi | update_template | PUT /v1.1/apps/appId/templates/templateId | |
SmoochApi::WebhookApi | create_webhook | POST /v1.1/apps/appId/webhooks | |
SmoochApi::WebhookApi | delete_webhook | DELETE /v1.1/apps/appId/webhooks/webhookId | |
SmoochApi::WebhookApi | get_webhook | GET /v1.1/apps/appId/webhooks/webhookId | |
SmoochApi::WebhookApi | list_webhooks | GET /v1.1/apps/appId/webhooks | |
SmoochApi::WebhookApi | update_webhook | PUT /v1.1/apps/appId/webhooks/webhookId |
Documentation for Models
- SmoochApi::Action
- SmoochApi::App
- SmoochApi::AppCreate
- SmoochApi::AppResponse
- SmoochApi::AppSettings
- SmoochApi::AppUpdate
- SmoochApi::AppUser
- SmoochApi::AppUserBusinessSystemsResponse
- SmoochApi::AppUserChannelsResponse
- SmoochApi::AppUserLink
- SmoochApi::AppUserPreCreate
- SmoochApi::AppUserResponse
- SmoochApi::AppUserUpdate
- SmoochApi::AttachmentRemove
- SmoochApi::AttachmentResponse
- SmoochApi::AuthCodeResponse
- SmoochApi::BusinessSystemItem
- SmoochApi::ChannelEntityItem
- SmoochApi::Client
- SmoochApi::ClientInfo
- SmoochApi::Confirmation
- SmoochApi::Conversation
- SmoochApi::Destination
- SmoochApi::DisplaySettings
- SmoochApi::GetMessagesResponse
- SmoochApi::Integration
- SmoochApi::IntegrationCreate
- SmoochApi::IntegrationProfileUpdate
- SmoochApi::IntegrationResponse
- SmoochApi::IntegrationUpdate
- SmoochApi::JwtResponse
- SmoochApi::LinkRequestResponse
- SmoochApi::LinkRequestResponseLinkRequests
- SmoochApi::ListAppsResponse
- SmoochApi::ListIntegrationsResponse
- SmoochApi::ListSecretKeysResponse
- SmoochApi::ListServiceAccountsResponse
- SmoochApi::ListTemplatesResponse
- SmoochApi::ListWebhooksResponse
- SmoochApi::Menu
- SmoochApi::MenuItem
- SmoochApi::MenuResponse
- SmoochApi::Message
- SmoochApi::MessageItem
- SmoochApi::MessageOverride
- SmoochApi::MessageOverrideWhatsapp
- SmoochApi::MessagePost
- SmoochApi::MessageResponse
- SmoochApi::SecretKey
- SmoochApi::SecretKeyCreate
- SmoochApi::SecretKeyResponse
- SmoochApi::ServiceAccount
- SmoochApi::ServiceAccountCreate
- SmoochApi::ServiceAccountResponse
- SmoochApi::ServiceAccountUpdate
- SmoochApi::Source
- SmoochApi::SubMenuItem
- SmoochApi::Template
- SmoochApi::TemplateCreate
- SmoochApi::TemplateResponse
- SmoochApi::TemplateUpdate
- SmoochApi::TypingActivityTrigger
- SmoochApi::Webhook
- SmoochApi::WebhookCreate
- SmoochApi::WebhookResponse
- SmoochApi::WebhookUpdate
Documentation for Authorization
jwt
- Type: API key
- API key parameter name: Authorization
- Location: HTTP header