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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/presbeus.rb +20 -7
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 856273ec05329e38a5f7abf9782e5bb771c352f0ca968a5faac2c4588c2eaec5
4
- data.tar.gz: a4586bbefa4437358422c3cd599e3e44c5fc66aef1c13dc6fe0fab5163f7de1e
3
+ metadata.gz: 1e7633c37a27646e9152e26c23931083387d27ccfb8c44cd46d4400afb4e8df3
4
+ data.tar.gz: 77edadaa30fd8fdd5dc13acd5c8da38ae76980f424439bf188984ccc2b234b27
5
5
  SHA512:
6
- metadata.gz: 45c2f4538118303af12075b5d63f80cd9a0994c1e5ce2da8d74a6618c7dcde06a8967e4b3b3c4c91c89fe62df1e8c2b68292f368e4a26163baa7cda3918d5dd8
7
- data.tar.gz: 7165dd3c6072f47609e7ed60c0f04c3180141d54aad9438f49fc10685f58cd607d7f3c63874b70beca3ffb0504ecb80ea6b2d2a53f3565aadcd72578eee3f366
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
- RestClient.post(
93
- @api_prefix + what, payload.to_json, @headers)
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
- response = RestClient.get(
98
- @api_prefix + what, @headers)
99
- JSON.parse response.body
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
- [thread["id"]] + thread["recipients"].map { |r| [r["address"], r["name"]] }.flatten
123
+ parse_thread thread
111
124
  end
112
125
  end
113
126
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: presbeus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier Abdesselam