Skip to content

whatsgate/ruby_sdk

Repository files navigation

swagger_client

SwaggerClient - the Ruby gem for the API whatsgate.ru

Интерфейс для взаимодействия с клиентом Whatsapp

This SDK is automatically generated by the Swagger Codegen project:

  • API version: 1.0.0
  • Package version: 1.0.0
  • Build package: io.swagger.codegen.v3.generators.ruby.RubyClientCodegen For more information, please visit https://whatsgate.ru/

Installation

Build a gem

To build the Ruby code into a gem:

gem build swagger_client.gemspec

Then either install the gem locally:

gem install ./swagger_client-1.0.0.gem

(for development, run gem install --dev ./swagger_client-1.0.0.gem to install the development dependencies)

or publish the gem to a gem hosting service, e.g. RubyGems.

Finally add this to the Gemfile:

gem 'swagger_client', '~> 1.0.0'

Install from Git

If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile:

gem 'swagger_client', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'

Include the Ruby code directly

Include the Ruby code directly using -I as follows:

ruby -Ilib script.rb

Getting Started

Please follow the installation procedure and then run the following code:

# Load the gem
require 'swagger_client'
# Setup authorization
SwaggerClient.configure do |config|
  # Configure API key authorization: ApiKeyAuth
  config.api_key['X-API-Key'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['X-API-Key'] = 'Bearer'
end

api_instance = SwaggerClient::DefaultApi.new
body = SwaggerClient::CheckBody.new # CheckBody | Проверяет, зарегистрирован ли указанный номер в WhatsApp. Номер указывается в формате только цифр, например 79999999999


begin
  #Проверка зарегистрирован ли номер в WhatsApp
  result = api_instance.check_post(body)
  p result
rescue SwaggerClient::ApiError => e
  puts "Exception when calling DefaultApi->check_post: #{e}"
end
# Setup authorization
SwaggerClient.configure do |config|
  # Configure API key authorization: ApiKeyAuth
  config.api_key['X-API-Key'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['X-API-Key'] = 'Bearer'
end

api_instance = SwaggerClient::DefaultApi.new
body = SwaggerClient::GetchatsBody.new # GetchatsBody | Запрашивает и возвращает список активных чатов, включая контакты и группы. В объекте группы находится идентификатор группы, список всех участников группы, права участников (является ли участник администратором группы).


begin
  #Возвращает список активных чатов
  result = api_instance.get_chats_post(body)
  p result
rescue SwaggerClient::ApiError => e
  puts "Exception when calling DefaultApi->get_chats_post: #{e}"
end
# Setup authorization
SwaggerClient.configure do |config|
  # Configure API key authorization: ApiKeyAuth
  config.api_key['X-API-Key'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['X-API-Key'] = 'Bearer'
end

api_instance = SwaggerClient::DefaultApi.new
body = SwaggerClient::SeenBody.new # SeenBody | Команда устанавливает у всех сообщений в указанном чате статус просмотрены.


begin
  #Отправляет команду в чат, что последние сообщения просмотрены
  result = api_instance.seen_post(body)
  p result
rescue SwaggerClient::ApiError => e
  puts "Exception when calling DefaultApi->seen_post: #{e}"
end
# Setup authorization
SwaggerClient.configure do |config|
  # Configure API key authorization: ApiKeyAuth
  config.api_key['X-API-Key'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['X-API-Key'] = 'Bearer'
end

api_instance = SwaggerClient::DefaultApi.new
body = SwaggerClient::SendBody.new # SendBody | Отправляет текстовое или мультимедийное сообщение контакту либо группе. Может использоваться синхронно (возвращает ответ после отправки сообщения, ответ содержит объект отправленного сообщения с идентификатором), либо асинхронно (ответ содержит результат постановки в очередь, а отправленное сообщение приходит на указанный webhook). По умолчанию используется асинхронная отправка.


begin
  #Отправка сообщения
  result = api_instance.send_message(body)
  p result
rescue SwaggerClient::ApiError => e
  puts "Exception when calling DefaultApi->send_message: #{e}"
end
# Setup authorization
SwaggerClient.configure do |config|
  # Configure API key authorization: ApiKeyAuth
  config.api_key['X-API-Key'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  #config.api_key_prefix['X-API-Key'] = 'Bearer'
end

api_instance = SwaggerClient::_Api.new
body = SwaggerClient::GetmediaBody.new # GetmediaBody | Запрашивает и возвращает медиа-файл, прикрепленный к сообщению по идентификатору mediaKey.


begin
  #Возвращает объект медиафайла, прикрепленного к сообщению
  result = api_instance.get_media_post(body)
  p result
rescue SwaggerClient::ApiError => e
  puts "Exception when calling _Api->get_media_post: #{e}"
end

Documentation for API Endpoints

All URIs are relative to https://whatsgate.ru/v1

Class Method HTTP request Description
SwaggerClient::DefaultApi check_post POST /check Проверка зарегистрирован ли номер в WhatsApp
SwaggerClient::DefaultApi get_chats_post POST /get-chats Возвращает список активных чатов
SwaggerClient::DefaultApi seen_post POST /seen Отправляет команду в чат, что последние сообщения просмотрены
SwaggerClient::DefaultApi send_message POST /send Отправка сообщения
SwaggerClient::_Api get_media_post POST /get-media Возвращает объект медиафайла, прикрепленного к сообщению

Documentation for Models

Documentation for Authorization

ApiKeyAuth

  • Type: API key
  • API key parameter name: X-API-Key
  • Location: HTTP header

About

the Ruby gem for the API whatsgate.ru

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published