essential 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -17
- data/lib/essential.rb +0 -1
- data/lib/essential/messaging/subscriber.rb +0 -9
- data/lib/essential/resource/paginator_proxy.rb +12 -10
- data/lib/essential/version.rb +1 -1
- metadata +1 -4
- data/lib/essential/messaging/property.rb +0 -27
- data/test/essential/messaging/property_test.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0294238d2f9124a97f0c5c0c32f36a38280fc357
|
4
|
+
data.tar.gz: f26dba74bc362acf8f9cb59af12a6b7fb95ed560
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 136ca9cff95bde947f462bd8c5a8f02a407868d1720c5cb47761cefb59e84ee19a889733ebb346d94dc4a8cd3c79d46071ca2c05f2923713bf1fa332e70995b0
|
7
|
+
data.tar.gz: 3c8d1bf4e9424b0a2c89b36552f357ba9872a615e536339174d4a2917447f2f45b54f4499dd6cdfb02915571a57348ca96a9261cbd83b2ff37aff7187c3adc7c
|
data/README.md
CHANGED
@@ -88,20 +88,3 @@ message = Essential::Messaging::Message.create(
|
|
88
88
|
body: 'explicit channel'
|
89
89
|
)
|
90
90
|
```
|
91
|
-
|
92
|
-
### Properties
|
93
|
-
|
94
|
-
```ruby
|
95
|
-
subscriber = channel.subscribers.create(phone_number: '2065551212')
|
96
|
-
|
97
|
-
# set new properties
|
98
|
-
subscriber.properties.create(name: 'external_id', value: 1234)
|
99
|
-
subscriber.properties.create(name: 'name', value: 'Brendan Ribera')
|
100
|
-
subscriber.properties.create(name: 'state', value: 'WA')
|
101
|
-
|
102
|
-
# print them
|
103
|
-
puts JSON.pretty_generate(subscriber.properties.as_json)
|
104
|
-
|
105
|
-
# update one
|
106
|
-
subscriber.properties.create(name: 'name', value: 'Nabnerb Arebir')
|
107
|
-
```
|
data/lib/essential.rb
CHANGED
@@ -15,7 +15,6 @@ require 'essential/account'
|
|
15
15
|
|
16
16
|
# Messaging Resources
|
17
17
|
require 'essential/messaging/message'
|
18
|
-
require 'essential/messaging/property'
|
19
18
|
require 'essential/messaging/transport'
|
20
19
|
require 'essential/messaging/subscriber'
|
21
20
|
require 'essential/messaging/channel'
|
@@ -27,15 +27,6 @@ module Essential::Messaging
|
|
27
27
|
)
|
28
28
|
end
|
29
29
|
|
30
|
-
def properties
|
31
|
-
Essential::Resource::PaginatorProxy.new(
|
32
|
-
Property,
|
33
|
-
url: Property.url(self.sid),
|
34
|
-
headers: @headers,
|
35
|
-
attrs: {subscriber_sid: self.sid},
|
36
|
-
)
|
37
|
-
end
|
38
|
-
|
39
30
|
def self.by_carrier(params: {}, headers: @headers)
|
40
31
|
# permitted:
|
41
32
|
# :start_date, :end_date, :carrier
|
@@ -62,18 +62,20 @@ module Essential
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def inspect
|
65
|
+
innards = [:proxied_class, :total, :per_page, :headers, :params].map do |m|
|
66
|
+
attr = self.send(m)
|
67
|
+
if attr
|
68
|
+
format(' @%s=%s', m, attr.inspect)
|
69
|
+
else
|
70
|
+
nil
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
65
74
|
format(
|
66
|
-
|
75
|
+
"#<%s:0x%s\n%s\n>",
|
67
76
|
self.class.name,
|
68
77
|
(self.object_id << 1).to_s(16),
|
69
|
-
|
70
|
-
attr = self.send(m)
|
71
|
-
if attr
|
72
|
-
format('@%s=%s', m, attr.inspect)
|
73
|
-
else
|
74
|
-
nil
|
75
|
-
end
|
76
|
-
end.compact.join(', ')
|
78
|
+
innards.compact.join(",\n")
|
77
79
|
)
|
78
80
|
end
|
79
81
|
|
@@ -98,7 +100,7 @@ module Essential
|
|
98
100
|
|
99
101
|
json = JSON.parse(response)
|
100
102
|
@fetched_pages[page || 1] = json.map do |json|
|
101
|
-
# persist @attrs across returned objects
|
103
|
+
# persist @attrs across returned objects
|
102
104
|
attrs = @attrs.merge(json)
|
103
105
|
@proxied_class.from_attributes(attrs, headers: @headers)
|
104
106
|
end
|
data/lib/essential/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: essential
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brendan Ribera
|
@@ -70,7 +70,6 @@ files:
|
|
70
70
|
- lib/essential/errors/api_error.rb
|
71
71
|
- lib/essential/messaging/channel.rb
|
72
72
|
- lib/essential/messaging/message.rb
|
73
|
-
- lib/essential/messaging/property.rb
|
74
73
|
- lib/essential/messaging/subscriber.rb
|
75
74
|
- lib/essential/messaging/transport.rb
|
76
75
|
- lib/essential/resource.rb
|
@@ -85,7 +84,6 @@ files:
|
|
85
84
|
- test/essential/account_test.rb
|
86
85
|
- test/essential/messaging/channel_test.rb
|
87
86
|
- test/essential/messaging/message_test.rb
|
88
|
-
- test/essential/messaging/property_test.rb
|
89
87
|
- test/essential/messaging/subscriber_test.rb
|
90
88
|
- test/essential/messaging/transport_test.rb
|
91
89
|
- test/integration/alternate_authentication_test.rb
|
@@ -118,7 +116,6 @@ test_files:
|
|
118
116
|
- test/essential/account_test.rb
|
119
117
|
- test/essential/messaging/channel_test.rb
|
120
118
|
- test/essential/messaging/message_test.rb
|
121
|
-
- test/essential/messaging/property_test.rb
|
122
119
|
- test/essential/messaging/subscriber_test.rb
|
123
120
|
- test/essential/messaging/transport_test.rb
|
124
121
|
- test/integration/alternate_authentication_test.rb
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Essential::Messaging
|
2
|
-
class Property < Essential::Resource
|
3
|
-
include Essential::Resource::Update
|
4
|
-
include Essential::Resource::Delete
|
5
|
-
|
6
|
-
undef_method :sid
|
7
|
-
attr_property :subscriber_sid, :name, :value
|
8
|
-
|
9
|
-
def self.retrieve(*args)
|
10
|
-
raise NotImplementedError, 'must be retrieved from a Subscriber'
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.url(subscriber_sid)
|
14
|
-
format('%s/%s/properties', Subscriber.url, CGI.escape(subscriber_sid))
|
15
|
-
end
|
16
|
-
|
17
|
-
def url
|
18
|
-
format('%s/%s', self.class.url(subscriber_sid), CGI.escape(name))
|
19
|
-
end
|
20
|
-
|
21
|
-
protected
|
22
|
-
|
23
|
-
def loaded?
|
24
|
-
@attributes.key?('name') && @attributes.key?('value')
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class PropertyTest < EssentialTest
|
4
|
-
def setup
|
5
|
-
channel = Essential::Messaging::Channel.list.first
|
6
|
-
@sub_a = channel.subscribers.create(phone_number: '2221110000')
|
7
|
-
@sub_b = channel.subscribers.create(phone_number: '2221110001')
|
8
|
-
refute_equal @sub_a, @sub_b, 'test requires at least two subscribers'
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_set_props
|
12
|
-
props_a = @sub_a.properties
|
13
|
-
existing_names = Set.new(props_a.map(&:name))
|
14
|
-
|
15
|
-
five_new = (5.times).map do
|
16
|
-
props_a.create(name: SecureRandom.uuid, value: SecureRandom.uuid)
|
17
|
-
end
|
18
|
-
|
19
|
-
new_names = Set.new(five_new.map(&:name))
|
20
|
-
|
21
|
-
assert (existing_names & new_names).empty?, 'new_names must be new'
|
22
|
-
|
23
|
-
props_a.refresh
|
24
|
-
existing_names = Set.new(props_a.map(&:name))
|
25
|
-
assert_equal (existing_names & new_names), new_names, 'must contain all new_names'
|
26
|
-
end
|
27
|
-
end
|