bottle_ruby 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/api_objects/message.rb +47 -0
- data/lib/bottle_ruby.rb +27 -0
- data/lib/client/rest_calls.rb +16 -0
- data/lib/extensions/hash.rb +7 -0
- metadata +33 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc97ccad11e672b02923db1f7295ba6dc3648561
|
4
|
+
data.tar.gz: 3ff2ac18c9894226ccc0b7f52d0451b99daf4f9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 298b71faf9d4874657a8089d497387c94f8d869ac59b5b79a066600b7d1e3bcc54f7d7e552e2eccb3632d981825f7481b81cd24ec9e36e4cbb4b98acc7fff551
|
7
|
+
data.tar.gz: 1ae9d2b17d473bbcd659f59c9319a507c8f5b291f76a26bde3e7c85e5dac7904253c2cb13d41aedb72809a6c51541bcd9275318e1502509583b79ce725a893c8
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Bottle
|
2
|
+
class Message
|
3
|
+
|
4
|
+
attr_accessor :to, :name, :body, :file, :tags,
|
5
|
+
:id, :from_number, :to_number, :delivered_at, :viewed_at, :created_at, :updated_at, :direction, :conversation_id, :origin, :object_name, :object_key, :user_id, :created_from_rule_id, :body_decoded, :attachments
|
6
|
+
|
7
|
+
|
8
|
+
def initialize(to=nil, name=nil, body=nil, file=nil, tags=nil)
|
9
|
+
@url_extension = 'messages'
|
10
|
+
if to.is_a?(Hash)
|
11
|
+
attributes = to.convert_keys_to_symbols
|
12
|
+
@to = attributes[:to]
|
13
|
+
@name = attributes[:name]
|
14
|
+
@body = attributes[:body]
|
15
|
+
@file = attributes[:file]
|
16
|
+
@tags = attributes[:tags]
|
17
|
+
@id = attributes[:id]
|
18
|
+
@from_number = attributes[:from_number]
|
19
|
+
@to_number = attributes[:to_number]
|
20
|
+
@delivered_at = attributes[:delivered_at]
|
21
|
+
@viewed_at = attributes[:viewed_at]
|
22
|
+
@created_at = attributes[:created_at]
|
23
|
+
@updated_at = attributes[:updated_at]
|
24
|
+
@direction = attributes[:direction]
|
25
|
+
@conversation_id = attributes[:conversation_id]
|
26
|
+
@origin = attributes[:origin]
|
27
|
+
@object_name = attributes[:object_name]
|
28
|
+
@object_key = attributes[:object_key]
|
29
|
+
@user_id = attributes[:user_id]
|
30
|
+
@created_from_rule_id = attributes[:created_from_rule_id]
|
31
|
+
@body_decoded = attributes[:body_decoded]
|
32
|
+
@attachments = attributes[:attachments]
|
33
|
+
else
|
34
|
+
@to = to
|
35
|
+
@name = name
|
36
|
+
@body = body
|
37
|
+
@file = file
|
38
|
+
@tags = tags
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def send(client)
|
43
|
+
client.post(@url_extension, {message: {to: self.to, name: self.name, text: self.body, file: self.file}, conversation: {tags: self.tags}})
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
data/lib/bottle_ruby.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
require 'api_objects/message'
|
5
|
+
require 'client/rest_calls'
|
6
|
+
require 'extensions/hash'
|
7
|
+
|
8
|
+
module Bottle
|
9
|
+
|
10
|
+
class Client
|
11
|
+
|
12
|
+
def initialize(uid, token)
|
13
|
+
@uid = uid
|
14
|
+
@token = token
|
15
|
+
end
|
16
|
+
|
17
|
+
def uid
|
18
|
+
@uid
|
19
|
+
end
|
20
|
+
|
21
|
+
def token
|
22
|
+
@token
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
API_URL = "https://sendbottles.com/api/v1/"
|
2
|
+
# API_URL = "https://mercyapp-staging.herokuapp.com/api/v1/"
|
3
|
+
|
4
|
+
class Bottle::Client
|
5
|
+
|
6
|
+
def request()
|
7
|
+
end
|
8
|
+
|
9
|
+
def post(url_extension, params)
|
10
|
+
connection = Faraday.new(url: API_URL)
|
11
|
+
response = connection.post(url_extension, params.merge({uid: self.uid, token: self.token}))
|
12
|
+
message_attributes = JSON.parse(response.body)
|
13
|
+
return Bottle::Message.new(message_attributes)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bottle_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Schreiber
|
@@ -10,14 +10,45 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
date: 2017-06-07 00:00:00.000000000 Z
|
13
|
-
dependencies:
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: json
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
14
42
|
description: Interact with the Bottle API in ruby.
|
15
43
|
email: will@sendbottles.com
|
16
44
|
executables: []
|
17
45
|
extensions: []
|
18
46
|
extra_rdoc_files: []
|
19
47
|
files:
|
48
|
+
- lib/api_objects/message.rb
|
20
49
|
- lib/bottle_ruby.rb
|
50
|
+
- lib/client/rest_calls.rb
|
51
|
+
- lib/extensions/hash.rb
|
21
52
|
homepage: https://rubygems.org/gems/bottle_ruby
|
22
53
|
licenses:
|
23
54
|
- MIT
|