layer-ruby 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58ca734ddad52fe657c82a0c35ed61b14f843746
4
- data.tar.gz: aa3c937660b78082c8107302b09237b62e68cac8
3
+ metadata.gz: 7e330978c530e5b073e3862a781956883f1a5e3c
4
+ data.tar.gz: f6ddf78a841b10618b5dd7063b33d8df3c49a96d
5
5
  SHA512:
6
- metadata.gz: 7b786542589ffed000d292fdbfa4e467eef9497f4a872fa47b27620120a2719174a146c503e0bbc878d41f272aaca6570c18183b5ff99c80c5870e025e23dd39
7
- data.tar.gz: d66c97971bc35d77416d0d27f1a4aeb0c69b50af89b209c60a515e4193fa3f931459b7ac46d3ae3d314126f1482e60e381431f04d97ecaa3c49555c3d89cda81
6
+ metadata.gz: 560c1c59d76250aee0b52c380de3c21fea72505210bc2b45b983de91b7c2b36f75c0fc811c1acc53b84aca9d51c35f541b8363bd3aa24cd012b186f252420a48
7
+ data.tar.gz: 3d24d1e1d13e454002950057ba82bed4f25c1f26a0ea40199c802125c4f49c764bedd7f868544a55e6311f3bb5567fd8e4706fe8a4f0b9b1c4543380c7df0976
@@ -25,8 +25,31 @@ module Layer
25
25
  # @!parse extend Layer::Operations::Find::ClassMethods
26
26
  # @!parse extend Layer::Operations::Paginate::ClassMethods
27
27
  # @!parse extend Layer::Operations::Create::ClassMethods
28
- # @!parse extend Layer::Operations::Delete::ClassMethods
29
- # @!parse extend Layer::Operations::Destroy::ClassMethods
28
+
29
+ # Deletes the resource with the given id
30
+ #
31
+ # In the REST API, this deletes the conversation for the current user only
32
+ #
33
+ # @param id [String] the resource's id
34
+ # @param options [Hash] the options for the delete request (REST API only: `leave: true/false`, `mode: all_participants/my_devices`)
35
+ # @param client [Layer::Client] the client to use to make this request
36
+ # @raise [Layer::Exceptions::Exception] a subclass of Layer::Exceptions::Exception describing the error
37
+ def self.delete(id, options = {}, client = self.client)
38
+ id = Layer::Client.normalize_id(id)
39
+ options = { mode: :my_devices }.merge(options)
40
+ client.delete("#{url}/#{id}", {}, { params: options })
41
+ end
42
+
43
+ # Destroys the resource with the given id
44
+ #
45
+ # In the REST API, this deletes the conversation for everyone
46
+ #
47
+ # @param id [String] the resource's id
48
+ # @param client [Layer::Client] the client to use to make this request
49
+ # @raise [Layer::Exceptions::Exception] a subclass of Layer::Exceptions::Exception describing the error
50
+ def self.destroy(id, client = self.client)
51
+ delete(id, { mode: :all_participants }, client)
52
+ end
30
53
 
31
54
  # Returns the conversations messages
32
55
  #
@@ -87,5 +110,21 @@ module Layer
87
110
  Time.parse(attributes['created_at'])
88
111
  end
89
112
 
113
+ # Destroys the conversation, removing it for everyone
114
+ #
115
+ # @raise [Layer::Exceptions::Exception] a subclass of Layer::Exceptions::Exception describing the error
116
+ def destroy
117
+ delete(mode: :all_participants)
118
+ end
119
+
120
+ # Deletes the conversation, removing it from the user's devices by default
121
+ #
122
+ # @param options [Hash] the options for the delete request (REST API only: `leave: true/false`, `mode: all_participants/my_devices`)
123
+ # @raise [Layer::Exceptions::Exception] a subclass of Layer::Exceptions::Exception describing the error
124
+ def delete(options = {})
125
+ options = { mode: :my_devices }.merge(options)
126
+ client.delete(url, {}, { params: options })
127
+ end
128
+
90
129
  end
91
130
  end
@@ -17,5 +17,16 @@ module Layer
17
17
  def self.url
18
18
  '/identity'
19
19
  end
20
+
21
+ def attributes=(attributes)
22
+ attributes['metadata'] ||= {}
23
+ super
24
+ end
25
+
26
+ def metadata=(metadata)
27
+ metadata.each_pair do |key, value|
28
+ self.metadata[key] = value
29
+ end
30
+ end
20
31
  end
21
32
  end
@@ -1,3 +1,3 @@
1
1
  module Layer
2
- VERSION = '0.7.1'
2
+ VERSION = '0.7.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: layer-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benedikt Deicke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-20 00:00:00.000000000 Z
11
+ date: 2017-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client