distributed-press-api-client 0.2.2 → 0.2.3

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
  SHA256:
3
- metadata.gz: 7cc2e318b07cdd179bf6a7817f3f35fbf0adb2ec2ea10c3a507b8f565605c469
4
- data.tar.gz: 51f43af7ba7cb51de03419f473cd20a3a39f42ff24542f8fb9a346bbbd8dc441
3
+ metadata.gz: 97a9c36acefc2ea476545820078749cba9d3a54c84e16ad179396193bbe4b9de
4
+ data.tar.gz: 6a20be7873ecaf8a11417511e493edf3cd041195cf55b7e4e785c9ae56e24c5a
5
5
  SHA512:
6
- metadata.gz: 64283cf5dc2a5bb7089917f09de9b43bdccccf748c83be099002b8e9676d065988d64571d4d9f0b599049cee2fe19d8627d7ddf476489a1078caa62c2056ca29
7
- data.tar.gz: eb252a94732ac916de5496f8ad74f0c19005a1f15c9c4776105c20f2a53cf61a6ad7d1637fecdbe10efa30a5b9e8898f37288bfbd60a0d6b3d83fe887bae830a
6
+ metadata.gz: d66d0f0b879114c2feab58a353ebd508a88f79e3d5d3d4e9f6b7f16c44cad6bcb9fd9358526f72acbfe0a92fc46eed168ebc158a1a6b01c1f122b7aedd06d2c1
7
+ data.tar.gz: 66edfeaa772e4b4fe763e67792ee1d1b15431714ef9a9c6fbbdf5ebd40edbd07cd62e710b598b0a4aca65d2c43fab36c202acb3bacafe78be8a47fb3112dc4f8
@@ -33,7 +33,7 @@ class DistributedPress
33
33
  validate_schema! schema
34
34
  validate_capabilities!
35
35
 
36
- client.delete(endpoint: "/v1/admin/#{schema[:id]}", schema: schema)
36
+ client.delete(endpoint: "/v1/admin/#{schema[:id]}")
37
37
  end
38
38
 
39
39
  private
@@ -35,7 +35,7 @@ class DistributedPress
35
35
 
36
36
  raise TokenCapabilityMissingError, 'Only admins can revoke tokens' unless client.token.admin?
37
37
 
38
- client.delete(endpoint: "/v1/auth/revoke/#{schema[:tokenId]}", schema: schema)
38
+ client.delete(endpoint: "/v1/auth/revoke/#{schema[:tokenId]}")
39
39
  end
40
40
 
41
41
  private
@@ -36,7 +36,7 @@ class DistributedPress
36
36
  validate_schema! schema
37
37
  validate_capabilities!
38
38
 
39
- client.delete(endpoint: "/v1/publisher/#{schema[:id]}", schema: schema)
39
+ client.delete(endpoint: "/v1/publisher/#{schema[:id]}")
40
40
  end
41
41
 
42
42
  private
@@ -65,7 +65,9 @@ class DistributedPress
65
65
  validate_capabilities!
66
66
  responses = []
67
67
 
68
- Open3.popen2('tar', '--to-stdout', '--create', '--gzip', '--dereference', '--directory', path,
68
+ Open3.popen2('tar', '--to-stdout', '--create', '--gzip',
69
+ '--dereference', '--exclude="*.gz"',
70
+ '--exclude="*.br"', '--directory', path,
69
71
  '.') do |_, stdout, thread|
70
72
  stream, body = IO.pipe
71
73
  multipart = Multipart.new
@@ -84,11 +86,18 @@ class DistributedPress
84
86
  responses << thread.value
85
87
  end
86
88
 
87
- responses.all? &:success?
89
+ responses.all?(&:success?)
88
90
  end
89
91
 
90
- def delete
91
- raise NotImplementedError
92
+ # Deletes a website
93
+ #
94
+ # @param schema [DistributedPress::V1::Schemas::Site]
95
+ # @return [Boolean]
96
+ def delete(schema)
97
+ validate_schema! schema
98
+ validate_capabilities!
99
+
100
+ client.delete(endpoint: "/v1/sites/#{schema[:id]}")
92
101
  end
93
102
 
94
103
  private
@@ -83,7 +83,8 @@ class DistributedPress
83
83
  multipart_headers['Content-Type'] = "multipart/form-data; boundary=#{boundary}"
84
84
  multipart_headers['Transfer-Encoding'] = 'chunked'
85
85
 
86
- self.class.put(endpoint, body_stream: io, headers: multipart_headers, max_retries: 0, timeout: timeout).tap do |response|
86
+ self.class.put(endpoint, body_stream: io, headers: multipart_headers, max_retries: 0,
87
+ timeout: timeout).tap do |response|
87
88
  process_response_errors! endpoint, response
88
89
  end
89
90
  end
@@ -99,8 +100,8 @@ class DistributedPress
99
100
  # @param endpoint [String]
100
101
  # @param schema [Dry::Schema::Result]
101
102
  # @return [Boolean]
102
- def delete(endpoint:, schema:)
103
- self.class.delete(endpoint, body: schema.to_h.to_json, headers: headers).tap do |response|
103
+ def delete(endpoint:)
104
+ self.class.delete(endpoint, headers: headers).tap do |response|
104
105
  process_response_errors! endpoint, response
105
106
  end.ok?
106
107
  end
@@ -137,7 +138,7 @@ class DistributedPress
137
138
  # @param response [HTTParty::Response]
138
139
  def process_response_errors!(endpoint, response)
139
140
  raise TokenUnauthorizedError if response.unauthorized?
140
- raise Error, "#{endpoint}: #{response.code} #{response.to_s.tr("\n", "")}" unless response.ok?
141
+ raise Error, "#{endpoint}: #{response.code} #{response.to_s.tr("\n", '')}" unless response.ok?
141
142
  end
142
143
  end
143
144
  end
@@ -3,5 +3,5 @@
3
3
  # API client
4
4
  class DistributedPress
5
5
  # Version
6
- VERSION = '0.2.2'
6
+ VERSION = '0.2.3'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: distributed-press-api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - f
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-08 00:00:00.000000000 Z
11
+ date: 2023-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable