ruby-vibe 0.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38ac243997c9534289e2c30281046b2e210c9e2190c10e5144378f84d33c917e
4
- data.tar.gz: 7b5f99b1d24ef41dd60ed6b8bd07591449789fc6945d73df58d284eeb042933f
3
+ metadata.gz: b502227c8730b2d5b3d98b9b58a94ee9d29bb24120699eb5dc748bb1b8217dd5
4
+ data.tar.gz: 1a3a64761ac1b43d3061bc2752b9653c2da4c275e596feed522efa302ea206ad
5
5
  SHA512:
6
- metadata.gz: bd56e369f03b2c0b591cdc0096c3f66c53c95feab97ef111bfcee2213ea840de40c638734df857c8d589853e1642689c73b7d8de44cd50047c073a01a1de4bf3
7
- data.tar.gz: b65e12ff689faad07beab6ada1934f638d769913db8325cc551625d1a35ec33a9d0e38d225652b29625550b9ec46ad436dfce517a44880b6840a22444fc9138f
6
+ metadata.gz: f910834235c9a6092ed771362b98a9bf243d82dd7a5dd533d4b8beceaecf0f6930e88a679eca9f85c852befd592690c25d497775d1787469e418bf4413918f02
7
+ data.tar.gz: 8778789d4c7f99e97c032df51e033288be10fb76af9d1a5b5fa77a16f7ae95650490894f566556fffe5cfa08c40a08c3ceed2528aa97dd94728b102574b28cfa
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'client'
4
+
5
+ module RubyVibe
6
+ ##
7
+ # Set of predefined viber api requests. This class is used directly by user.
8
+ # Define constants for configuration settings, or add them on initialization.
9
+ #
10
+ # @example Set default configuration
11
+ # RubyVibe::TOKEN = 'my_viber_auth_token'
12
+ # RubyVibe::NAME = 'my_viber_nickname'
13
+ # RubyVibe::AVATAR = 'avatar_url'
14
+ #
15
+ class Bot < RubyVibe::Client
16
+ ##
17
+ # @example Initialize new bot with user-defined configuration
18
+ # @bot = RubyVibe::Bot.new(token: 'auth_token',
19
+ # name: 'sender_name',
20
+ # avatar: 'https_avatar_url' )
21
+ #
22
+ # @param [String] token **Optional**. Auth token provided by Viber.
23
+ # @param [String] name **Optional**. Sender name provided by user.
24
+ # @param [String] avatar **Optional**. SSL link to user photo.
25
+ #
26
+ # @return [Bot] Bot object to work with.
27
+ #
28
+ def initialize(token: nil, name: nil, avatar: nil)
29
+ token ||= RubyVibe::TOKEN
30
+ name ||= RubyVibe::NAME
31
+ avatar ||= RubyVibe::AVATAR
32
+
33
+ super(token: token, name: name, avatar: avatar)
34
+ end
35
+
36
+ ##
37
+ # Send message to user.
38
+ # @see https://developers.viber.com/docs/api/rest-bot-api/#send-message
39
+ #
40
+ # @param [Hash] opts
41
+ #
42
+ # @option opts [String] message **Required**. Message text
43
+ # @option opts [String] receiver **Required**. Message receiver
44
+ # @option opts [String] sender_name **Optional**. Sender name || RubyVibe::NAME
45
+ # @option opts [String] avatar **Optional**. Avatar url || RubyVibe::AVATAR
46
+ # @option opts [String] keyboard **Optional**. Add keyboard to message
47
+ # @option opts [String] rich_media **Optional**. Send rich_media message
48
+ #
49
+ # @return [Hash] Response hash defined in RubyVibe::Client
50
+ #
51
+ def send_message(opts = {})
52
+ viberize(URL::SEND_MESSAGE, opts)
53
+ end
54
+
55
+ ##
56
+ # Broadcast message to multiple users.
57
+ # @see https://developers.viber.com/docs/api/rest-bot-api/#broadcast-message
58
+ #
59
+ # @param [Hash] opts Viber API options for broadcast_message request
60
+ #
61
+ # @option opts [String] message **Required**. Message text
62
+ # @option opts [Array] receivers **Required**. Message receivers
63
+ # @option opts [String] sender_name **Optional**. Sender name || RubyVibe::NAME
64
+ # @option opts [String] avatar **Optional**. Avatar url || RubyVibe::AVATAR
65
+ # @option opts [String] keyboard **Optional**. Add keyboard to message
66
+ # @option opts [String] rich_media **Optional**. Send rich_media message
67
+ #
68
+ # @return [Hash] Response hash defined in RubyVibe::Client
69
+ #
70
+ def broadcast_message(opts = {})
71
+ viberize(URL::BROADCAST_MESSAGE, opts)
72
+ end
73
+
74
+ ##
75
+ # @see https://developers.viber.com/docs/api/rest-bot-api/#set-webhook
76
+ #
77
+ def set_webhook(opts = {})
78
+ viberize(URL::SET_WEBHOOK, opts)
79
+ end
80
+
81
+ ##
82
+ # @see https://developers.viber.com/docs/api/rest-bot-api/#get-account-info
83
+ #
84
+ def get_account_info
85
+ viberize(URL::GET_ACCOUNT_INFO, info: true)
86
+ end
87
+
88
+ ##
89
+ # @see https://developers.viber.com/docs/api/rest-bot-api/#get-user-details
90
+ #
91
+ def get_user_details(user_id)
92
+ viberize(URL::GET_USER_DETAILS, id: user_id, info: true)
93
+ end
94
+
95
+ ##
96
+ # @see https://developers.viber.com/docs/api/rest-bot-api/#get-online
97
+ #
98
+ def get_online(*user_ids)
99
+ viberize(URL::GET_ONLINE, ids: Array(user_ids), info: true)
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,129 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rest-client'
4
+ require 'json'
5
+
6
+ module RubyVibe
7
+ ##
8
+ # This class is almost never used directly by user.
9
+ # Send actual request to viber api and perform type validation
10
+ # for token, name and avatar (must be strings).
11
+ #
12
+ class Client
13
+ attr_accessor :token, :name, :avatar
14
+
15
+ attr_reader :response, :payload_hash
16
+
17
+ alias sender name
18
+
19
+ ##
20
+ # @example Initialize new client
21
+ #
22
+ # @client = Client.new(token: 'token', name: 'name', avatar: 'https_url')
23
+ #
24
+ # @param [String] token **Required**. Viber auth token.
25
+ # @param [String] name **Required**. Sender name.
26
+ # @param [String] avatar **Optional**. Avatar url.
27
+ #
28
+ # @raise [Token must be string] Token must be string.
29
+ # @raise [Name must be string] Name must be string.
30
+ # @raise [Avatar must use SSL] If defined, avatar must use https connection.
31
+ #
32
+ # @return [Object]
33
+ #
34
+ def initialize(token: nil, name: nil, avatar: nil)
35
+ raise 'Token must be string!' unless token.is_a? String
36
+ raise 'Sender name must be string' unless name.is_a? String
37
+
38
+ raise 'Avatar URL must use SSL' if !avatar.empty? && !(avatar.start_with? 'https://')
39
+
40
+ @token = token
41
+ @name = name
42
+ @avatar = avatar
43
+ end
44
+
45
+ private
46
+
47
+ ##
48
+ # Send payload to Viber API.
49
+ #
50
+ # @param [String] url **Required**. API url to send payload.
51
+ # @param [Hash] payload **Optional**. Payload to send with request.
52
+ # @return [Hash] Bot#response hash with all data.
53
+ #
54
+ def action(url, payload: {})
55
+ headers = {
56
+ 'User-Agent': "RubyVibe client v#{RubyVibe::VERSION})",
57
+ 'X-Viber-Auth-Token': @token
58
+ }
59
+
60
+ response = ::RestClient::Request.execute(
61
+ method: :post,
62
+ url: url,
63
+ payload: payload.to_json,
64
+ headers: headers,
65
+ timeout: 5,
66
+ verify_ssl: ::OpenSSL::SSL::VERIFY_NONE
67
+ )
68
+
69
+ @response = parse(response)
70
+ end
71
+
72
+ ##
73
+ # Method used by bot to construct viber api request.
74
+ # Prepare payload and send it to api url.
75
+ #
76
+ # @param [String] api_url **Required**. URL corresponding to method name.
77
+ # @param [Hash] opts **Optional**. Payload corresponding to method options.
78
+ #
79
+ def viberize(api_url, opts = {})
80
+ payload = load_payload(opts)
81
+ action(api_url, payload: payload)
82
+ end
83
+
84
+ ##
85
+ # Construct payload to send with request.
86
+ # If payload contain `info: true`, do not add sender name and avatar url.
87
+ # Otherwise, add them together with _options hash_ to payload.
88
+ # Nil values are not imported.
89
+ #
90
+ # @param [Hash] opts **Optional**. Data to create payload.
91
+ # @return [Hash] Client#payload_hash to send with request.
92
+ #
93
+ def load_payload(opts = {})
94
+ @payload_hash = {}
95
+
96
+ if opts[:info].nil?
97
+ @payload_hash[:sender] = {
98
+ sender_name: opts[:sender_name] || @name,
99
+ avatar: opts[:sender_avatar] || @avatar
100
+ }
101
+ end
102
+
103
+ opts.map do |key, value|
104
+ next if value.nil?
105
+ next if key == :info
106
+
107
+ @payload_hash[key] = value
108
+ end
109
+ @payload_hash
110
+ end
111
+
112
+ ##
113
+ # Construct response hash. Parse viber response and check status code.
114
+ # If code is not zero (**0**), add `error_message` to response.
115
+ #
116
+ def parse(response)
117
+ success = true
118
+ error_message = nil
119
+ hash = JSON.parse(response.body)
120
+
121
+ unless hash['status'].to_i.zero?
122
+ success = false
123
+ error_message = hash['status_message']
124
+ end
125
+
126
+ Struct.new(:success?, :data, :error_message).new(success, hash, error_message)
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyVibe
4
+ ##
5
+ # Shortcut to initialize Bot and send message.
6
+ # @see https://developers.viber.com/docs/api/rest-bot-api/#send-message
7
+ #
8
+ # @note Configuration constants must be defined to use this class.
9
+ #
10
+ # @example Configure constants
11
+ # RubyVibe::TOKEN = 'my_api_token'
12
+ # RubyVibe::NAME = 'my_nickname'
13
+ # RubyVibe::AVATAR = 'https_avatar_url'
14
+ #
15
+ # @example Send text message
16
+ # msg = RubyVibe::SendMessage[message: 'text', sender_name: 'my_nickname']
17
+ # pp msg.error_message unless msg.success?
18
+ #
19
+ class SendMessage
20
+ ##
21
+ # Send message to user.
22
+ #
23
+ # @param [Hash] opts
24
+ # @return [Data#response]
25
+ # @see Bot#send_message
26
+ #
27
+ def self.[](opts = {})
28
+ Bot.new.send_message(opts)
29
+ end
30
+ end
31
+
32
+ ##
33
+ # Shortcut to initialize Bot and broadcast message.
34
+ # @see https://developers.viber.com/docs/api/rest-bot-api/#broadcast-message
35
+ #
36
+ # @note Configuration constants must be defined to use shortcut classes
37
+ #
38
+ # @example Configure constants
39
+ # RubyVibe::TOKEN = 'my_api_token'
40
+ # RubyVibe::NAME = 'my_nickname'
41
+ # RubyVibe::AVATAR = 'https_avatar_url'
42
+ #
43
+ class BroadcastMessage
44
+ ##
45
+ # @example Broadcast message to multiple users
46
+ # msg = RubyVibe::BroadcastMessage[message: 'text',
47
+ # receivers: %w[user_1 user_2]
48
+ # ]
49
+ # pp msg.error_message unless msg.success?
50
+ #
51
+ def self.[](opts = {})
52
+ Bot.new.broadcast_message(opts)
53
+ end
54
+ end
55
+
56
+ ##
57
+ # @see https://developers.viber.com/docs/api/rest-bot-api/#set-webhook
58
+ #
59
+ class SetWebhook
60
+ # @note Configuration constants must be defined to use shortcut classes
61
+ def self.[](opts = {})
62
+ Bot.new.set_webhook(opts)
63
+ end
64
+ end
65
+
66
+ ##
67
+ # @see https://developers.viber.com/docs/api/rest-bot-api/#get-account-info
68
+ #
69
+ class GetAccountInfo
70
+ # @note Configuration constants must be defined to use shortcut classes
71
+ def self.[]
72
+ Bot.new.get_account_info
73
+ end
74
+ end
75
+
76
+ ##
77
+ # @see https://developers.viber.com/docs/api/rest-bot-api/#get-user-details
78
+ #
79
+ class GetUserDetails
80
+ # @note Configuration constants must be defined to use shortcut classes
81
+ def self.[](user_id)
82
+ Bot.new.get_user_details(user_id)
83
+ end
84
+ end
85
+
86
+ ##
87
+ # @see https://developers.viber.com/docs/api/rest-bot-api/#get-online
88
+ #
89
+ class GetOnline
90
+ # @note Configuration constants must be defined to use shortcut classes
91
+ def self.[](*user_ids)
92
+ Bot.new.get_online(*user_ids)
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ # Viber API urls as constant for corresponding method.
5
+ #
6
+ # @see https://developers.viber.com/docs/api/rest-bot-api
7
+ #
8
+ module URL
9
+ # viber api url
10
+ API = 'https://chatapi.viber.com/pa'
11
+
12
+ # api url to set webhook
13
+ SET_WEBHOOK = "#{API}/set_webhook".freeze
14
+
15
+ # api url to send message to user
16
+ SEND_MESSAGE = "#{API}/send_message".freeze
17
+
18
+ # api url to get info about your account
19
+ GET_ACCOUNT_INFO = "#{API}/get_account_info".freeze
20
+
21
+ # api url to get info about user (twice per 12h for each ID)
22
+ GET_USER_DETAILS = "#{API}/get_user_details".freeze
23
+
24
+ # api url to broadcast message to multiple users (must be subscribed to bot)
25
+ BROADCAST_MESSAGE = "#{API}/broadcast_message".freeze
26
+
27
+ # api url to check if user(s) is online
28
+ GET_ONLINE = "#{API}/get_online".freeze
29
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ # Gem version
5
+ #
6
+ module RubyVibe
7
+ # version number to change with new update
8
+ VERSION = '2.0.0'
9
+ end
data/lib/ruby_vibe.rb CHANGED
@@ -1,16 +1,29 @@
1
- require 'ruby_vibe/client'
2
- require 'ruby_vibe/calls'
3
- require 'ruby_vibe/version'
4
- require 'ruby_vibe/configuration'
5
- require 'ruby_vibe/urls'
1
+ # frozen_string_literal: true
6
2
 
7
- class RubyVibe
3
+ require_relative 'ruby-vibe/url'
4
+ require_relative 'ruby-vibe/bot'
5
+ require_relative 'ruby-vibe/shortcuts'
6
+ require_relative 'ruby-vibe/version'
8
7
 
9
- attr_accessor :client
10
-
11
- include Calls
8
+ ##
9
+ # RubyVibe represent a main module for Viber Bot.
10
+ # Multiple classes are used as shortcut classes,
11
+ # calling methods from RubyVibe::Bot class.
12
+ # Actual request to viber api is done by RubyVibe::Client class.
13
+ # Urls for viber API are defined in URL module.
14
+ #
15
+ # @see RubyVibe::Bot
16
+ # @see RubyVibe::Client
17
+ # @see URL
18
+ # @see [File] lib/ruby-vibe/shortcuts.rb
19
+ #
20
+ module RubyVibe
21
+ # viber api auth_token to be used if not given by user
22
+ TOKEN = ''
12
23
 
13
- def initialize(auth_token: nil)
14
- @client = Client.new(auth_token: auth_token)
15
- end
16
- end
24
+ # sender name to be used if not given by user
25
+ NAME = ''
26
+
27
+ # avatar url to be used if not given by user (require https)
28
+ AVATAR = ''
29
+ end
metadata CHANGED
@@ -1,43 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-vibe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adem Dinarevic
8
8
  autorequire:
9
- bindir: bin
9
+ bindir:
10
+ - bin
10
11
  cert_chain: []
11
- date: 2021-07-10 00:00:00.000000000 Z
12
+ date: 2022-01-24 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
- name: bundler
15
+ name: rest-client
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - '='
18
+ - - "~>"
18
19
  - !ruby/object:Gem::Version
19
- version: 2.1.4
20
+ version: 2.1.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 2.1.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: pry
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 0.14.1
20
35
  type: :development
21
36
  prerelease: false
22
37
  version_requirements: !ruby/object:Gem::Requirement
23
38
  requirements:
24
- - - '='
39
+ - - "~>"
25
40
  - !ruby/object:Gem::Version
26
- version: 2.1.4
41
+ version: 0.14.1
27
42
  - !ruby/object:Gem::Dependency
28
43
  name: rake
29
44
  requirement: !ruby/object:Gem::Requirement
30
45
  requirements:
31
46
  - - "~>"
32
47
  - !ruby/object:Gem::Version
33
- version: '10.0'
48
+ version: 13.0.3
34
49
  type: :development
35
50
  prerelease: false
36
51
  version_requirements: !ruby/object:Gem::Requirement
37
52
  requirements:
38
53
  - - "~>"
39
54
  - !ruby/object:Gem::Version
40
- version: '10.0'
55
+ version: 13.0.3
41
56
  - !ruby/object:Gem::Dependency
42
57
  name: rspec
43
58
  requirement: !ruby/object:Gem::Requirement
@@ -59,14 +74,12 @@ executables: []
59
74
  extensions: []
60
75
  extra_rdoc_files: []
61
76
  files:
77
+ - lib/ruby-vibe/bot.rb
78
+ - lib/ruby-vibe/client.rb
79
+ - lib/ruby-vibe/shortcuts.rb
80
+ - lib/ruby-vibe/url.rb
81
+ - lib/ruby-vibe/version.rb
62
82
  - lib/ruby_vibe.rb
63
- - lib/ruby_vibe/calls.rb
64
- - lib/ruby_vibe/calls/info.rb
65
- - lib/ruby_vibe/calls/messaging.rb
66
- - lib/ruby_vibe/client.rb
67
- - lib/ruby_vibe/configuration.rb
68
- - lib/ruby_vibe/urls.rb
69
- - lib/ruby_vibe/version.rb
70
83
  homepage: https://github.com/ademdc/ruby-vibe
71
84
  licenses:
72
85
  - MIT
@@ -79,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
92
  requirements:
80
93
  - - ">="
81
94
  - !ruby/object:Gem::Version
82
- version: '0'
95
+ version: 3.0.1
83
96
  required_rubygems_version: !ruby/object:Gem::Requirement
84
97
  requirements:
85
98
  - - ">="
@@ -1,37 +0,0 @@
1
- class RubyVibe
2
- module Calls
3
- module Info
4
-
5
- def get_account_data
6
- client.action(RubyVibe::URLS::GET_ACCOUNT_INFO)
7
- end
8
-
9
- def set_webhook(url, events: [], send_name: true, send_photo: true)
10
- payload = {
11
- url: url,
12
- event_types: events,
13
- send_name: send_name,
14
- send_photo: send_photo
15
- }
16
-
17
- client.action(RubyVibe::URLS::SET_WEBHOOK, payload: payload)
18
- end
19
-
20
- def get_user_details(user_id)
21
- payload = {
22
- id: user_id
23
- }
24
-
25
- client.action(RubyVibe::URLS::GET_USER_DETAILS, payload: payload)
26
- end
27
-
28
- def get_online(ids=[])
29
- payload = {
30
- ids: ids
31
- }
32
-
33
- client.action(RubyVibe::URLS::GET_ONLINE, payload: payload)
34
- end
35
- end
36
- end
37
- end
@@ -1,40 +0,0 @@
1
- class RubyVibe
2
- module Calls
3
- module Messaging
4
-
5
- def send_message(receiver:, text:, sender_name: nil, sender_avatar: nil, tracking_data: nil, type: 'text', keyboard: nil)
6
- payload = {
7
- receiver:receiver,
8
- sender:{
9
- name:sender_name || RubyVibe.config.sender_name,
10
- avatar:sender_avatar || RubyVibe.config.sender_avatar
11
- },
12
- tracking_data:tracking_data,
13
- type:type,
14
- text:text
15
- }.compact
16
-
17
- payload.merge!({ keyboard: keyboard }) unless keyboard.nil?
18
-
19
- client.action(RubyVibe::URLS::MESSAGE, payload: payload)
20
- end
21
-
22
- def broadcast_message(broadcast_list:[], text:, sender_name: nil, sender_avatar: nil, type: 'text', rich_media: nil, keyboard: nil)
23
- payload = {
24
- sender:{
25
- name: sender_name || RubyVibe.config.sender_name,
26
- avatar: sender_avatar || RubyVibe.config.sender_avatar
27
- },
28
- type: type,
29
- text: text,
30
- broadcast_list: broadcast_list,
31
- }
32
-
33
- payload.merge!({ rich_media: rich_media }) unless rich_media.nil?
34
- payload.merge!({ keyboard: keyboard }) unless keyboard.nil?
35
-
36
- client.action(RubyVibe::URLS::BROADCAST_MESSAGE, payload: payload)
37
- end
38
- end
39
- end
40
- end
@@ -1,9 +0,0 @@
1
- require 'ruby_vibe/calls/info'
2
- require 'ruby_vibe/calls/messaging'
3
-
4
- class RubyVibe
5
- module Calls
6
- include Info
7
- include Messaging
8
- end
9
- end
@@ -1,51 +0,0 @@
1
- require 'rest-client'
2
- require 'json'
3
- require 'byebug'
4
-
5
- class RubyVibe
6
- class Client
7
-
8
- attr_accessor :token
9
-
10
- def initialize(auth_token:)
11
- RubyVibe.configure
12
-
13
- @token = auth_token
14
- end
15
-
16
- def action(url, payload: {}, http_method: :post)
17
- headers = {
18
- 'User-Agent': "RubyVibe client v#{RubyVibe::VERSION})",
19
- 'X-Viber-Auth-Token': token || RubyVibe.config.auth_token
20
- }
21
-
22
- response = ::RestClient::Request.execute(
23
- method: http_method,
24
- url: url,
25
- payload: payload.to_json,
26
- headers: headers,
27
- timeout: 5,
28
- verify_ssl: ::OpenSSL::SSL::VERIFY_NONE
29
- )
30
-
31
- return_response(response)
32
- end
33
-
34
- private
35
-
36
- def return_response(response)
37
- success = true
38
- error_message = nil
39
- hash = JSON.parse(response.body)
40
-
41
- unless hash.dig('status').to_i == 0
42
- success = false
43
- error_message = hash.dig('status_message')
44
- end
45
-
46
-
47
- Struct.new(:success?, :hash, :error_message).new(success, hash, error_message)
48
- end
49
-
50
- end
51
- end
@@ -1,21 +0,0 @@
1
- class RubyVibe
2
- class << self
3
- # Accessor for global configuration.
4
- attr_accessor :config
5
- end
6
-
7
- def self.configure
8
- self.config ||= Configuration.new
9
- yield(config) if block_given?
10
- end
11
-
12
- class Configuration
13
- attr_accessor :auth_token, :sender_name, :sender_avatar
14
-
15
- def initialize
16
- @auth_token = nil
17
- @sender_name = nil
18
- @sender_avatar = 'http://avatar.example.com'
19
- end
20
- end
21
- end
@@ -1,11 +0,0 @@
1
- class RubyVibe
2
- module URLS
3
- API = 'https://chatapi.viber.com/pa'.freeze
4
- SET_WEBHOOK = "#{API}/set_webhook".freeze
5
- MESSAGE = "#{API}/send_message".freeze
6
- GET_ACCOUNT_INFO = "#{API}/get_account_info".freeze
7
- GET_USER_DETAILS = "#{API}/get_user_details".freeze
8
- BROADCAST_MESSAGE = "#{API}/broadcast_message".freeze
9
- GET_ONLINE = "#{API}/get_online".freeze
10
- end
11
- end
@@ -1,3 +0,0 @@
1
- class RubyVibe
2
- VERSION='0.0.1'.freeze
3
- end