presbeus 0.0.12 → 0.0.13
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 +4 -4
- data/lib/presbeus.rb +20 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e7633c37a27646e9152e26c23931083387d27ccfb8c44cd46d4400afb4e8df3
|
4
|
+
data.tar.gz: 77edadaa30fd8fdd5dc13acd5c8da38ae76980f424439bf188984ccc2b234b27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5226e7fba4cc0b882108612777ad1b45044a618a9c7d1b9102ece578928ca3e4c82fd131d74025e4a30c7e580168fb996147d1268bdc90cce30a944efd9affd0
|
7
|
+
data.tar.gz: '0693b4c79e124bfacf0c8c4ef55399d78be631ff88ce34195b2ebd59434bad80c2fdf6bdcf2fcd2625d0d90ba54a0c5deefce4f89aec0b5841897451aafae61e'
|
data/lib/presbeus.rb
CHANGED
@@ -43,7 +43,8 @@ class Presbeus
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
def initialize
|
46
|
+
def initialize client = true
|
47
|
+
@client = client
|
47
48
|
initialize_arguments
|
48
49
|
configuration_path = "#{ENV['HOME']}/.config/presbeus.yml"
|
49
50
|
configuration = YAML.load_file configuration_path
|
@@ -89,14 +90,22 @@ class Presbeus
|
|
89
90
|
end
|
90
91
|
|
91
92
|
def post_v2 what, payload
|
92
|
-
|
93
|
-
|
93
|
+
args = {url: @api_prefix + what, payload: payload.to_json, headers: @headers}
|
94
|
+
if @client
|
95
|
+
RestClient.post(args[:url], args[:payload], args[:headers])
|
96
|
+
else
|
97
|
+
args
|
98
|
+
end
|
94
99
|
end
|
95
100
|
|
96
101
|
def get_v2 what
|
97
|
-
|
98
|
-
|
99
|
-
|
102
|
+
args = {url: @api_prefix + what, headers: @headers}
|
103
|
+
if @client
|
104
|
+
response = RestClient.get(args[:url], args[:headers])
|
105
|
+
JSON.parse response.body
|
106
|
+
else
|
107
|
+
args
|
108
|
+
end
|
100
109
|
end
|
101
110
|
|
102
111
|
def devices
|
@@ -105,9 +114,13 @@ class Presbeus
|
|
105
114
|
end
|
106
115
|
end
|
107
116
|
|
117
|
+
def self.parse_thread thread
|
118
|
+
[thread["id"]] + thread["recipients"].map { |r| [r["address"], r["name"]] }.flatten
|
119
|
+
end
|
120
|
+
|
108
121
|
def threads iden
|
109
122
|
get_v2("permanents/#{iden}_threads")["threads"].reverse.map do |thread|
|
110
|
-
|
123
|
+
parse_thread thread
|
111
124
|
end
|
112
125
|
end
|
113
126
|
|