bottle_ruby 0.0.4 → 0.0.5

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
  SHA1:
3
- metadata.gz: a4bf99887ad8fa457d07744ba960204b2edd4cd2
4
- data.tar.gz: c651c0a7b11a207f6d174b9c1bad578f0e46fcf1
3
+ metadata.gz: 2225e480768a5c5e61476953388e0016a26df455
4
+ data.tar.gz: 9fb06709df920162d3b496f1bbfe8aa8da506a99
5
5
  SHA512:
6
- metadata.gz: 34cd1cf4666eea50721e029271ad836c829f14cc5f368f52e24660d6c87730365a4b69473577c0bbe88c676daa7aeb2a73e0b672d7e91c1eba592758aeee6693
7
- data.tar.gz: 3e4ca5b141688c30b590d8b3b203e4e13ba74aa41ea4cdf895cbc8ed4431bc2566591a1d2369d59e03614633ef66268d145403cce070e8083de5edbf22e53960
6
+ metadata.gz: e9122f02366863010a43a4ff19ab64297709a522fa7cf45f3d1594548740da13d72461abea1d44b8fc591e6d51d858a9d814800950fcb39036da5c349665bb6e
7
+ data.tar.gz: 059e23b3012535a4fa80b79ccf19db5b91d84dab4092a8c3f4f77c8fdcaa2784b08175d8fc0658af6200edba4f3eeefbc74ec144bd5dba0b782ec7baaa4cdef4
@@ -0,0 +1,49 @@
1
+ module Bottle
2
+ class Conversation
3
+
4
+ attr_accessor :phone, :handle, :name, :tags, :id, :conversation_id, :created_at, :updated_at, :relationship_status, :object_name, :object_key, :user_id, :last_viewed_timestamp, :conversation_name, :conversation_type, :conversation_status, :user_display_identifier, :avatar_color, :user_phone_active, :favorited, :last_sent_timestamp, :unread_count, :last_message_is_from_user, :conversation_title, :group_identifier
5
+
6
+
7
+ def initialize(phone=nil, handle=nil, name=nil, tags=nil)
8
+ @url_extension = 'conversations'
9
+ if phone.is_a?(Hash)
10
+ attributes = phone.convert_keys_to_symbols
11
+ @phone = attributes[:phone]
12
+ @handle = attributes[:handle]
13
+ @tags = attributes[:tags]
14
+ @name = attributes[:name]
15
+ @id = attributes[:id]
16
+ @conversation_id = attributes[:conversation_id]
17
+ @created_at = attributes[:created_at]
18
+ @updated_at = attributes[:updated_at]
19
+ @relationship_status = attributes[:relationship_status]
20
+ @object_name = attributes[:object_name]
21
+ @object_key = attributes[:object_key]
22
+ @user_id = attributes[:user_id]
23
+ @last_viewed_timestamp = attributes[:last_viewed_timestamp]
24
+ @conversation_name = attributes[:conversation_name]
25
+ @conversation_type = attributes[:conversation_type]
26
+ @conversation_status = attributes[:conversation_status]
27
+ @user_display_identifier = attributes[:user_display_identifier]
28
+ @avatar_color = attributes[:avatar_color]
29
+ @user_phone_active = attributes[:user_phone_active]
30
+ @favorited = attributes[:favorited]
31
+ @last_sent_timestamp = attributes[:last_sent_timestamp]
32
+ @unread_count = attributes[:unread_count]
33
+ @last_message_is_from_user = attributes[:last_message_is_from_user]
34
+ @conversation_title = attributes[:conversation_title]
35
+ @group_identifier = attributes[:group_identifier]
36
+ else
37
+ @phone = phone
38
+ @handle = handle
39
+ @name = name
40
+ @tags = tags
41
+ end
42
+ end
43
+
44
+ def send(client)
45
+ client.post(@url_extension, {conversation: {phone: self.phone, handle: self.handle, name: self.name, tags: self.tags}})
46
+ end
47
+
48
+ end
49
+ end
@@ -2,6 +2,7 @@ require 'faraday'
2
2
  require 'json'
3
3
 
4
4
  require 'api_objects/message'
5
+ require 'api_objects/conversation'
5
6
  require 'client/rest_calls'
6
7
  require 'extensions/hash'
7
8
 
@@ -9,8 +9,9 @@ class Bottle::Client
9
9
  def post(url_extension, params)
10
10
  connection = Faraday.new(url: API_URL)
11
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)
12
+ attributes = JSON.parse(response.body)
13
+ return Bottle::Message.new(attributes) if url_extension == 'messages'
14
+ return Bottle::Conversation.new(attributes) if url_extension == 'conversations'
14
15
  end
15
16
 
16
17
  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
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Schreiber
@@ -45,6 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - lib/api_objects/conversation.rb
48
49
  - lib/api_objects/message.rb
49
50
  - lib/bottle_ruby.rb
50
51
  - lib/client/rest_calls.rb