ruby-lokalise-api 2.9.0.1 → 2.10.0

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: 8aa6e75e9dc1a1222dcd06066268fc71f9729086ed10ebc612e42a4d2d28bc1b
4
- data.tar.gz: 7ee797f27ce71c74623fe7d86a89eaf0d7eeda018ca43d0b302c6f2fd4eedd9a
3
+ metadata.gz: 18ea61d6c137da44854cdee519355e5bdf9a9daafbe98328009d1eb82fa55853
4
+ data.tar.gz: 517820d0bd2a06c89d82fd3c690b7b450d34c12b1a97e5300dea9b9c1b7f342b
5
5
  SHA512:
6
- metadata.gz: 4e0cd4ffcc6be509e79fd841adc3cb06cf4650cdb8589506cc1d4ce6dd628aec27736924c0ac0af7ca3a6138d5f7370dd8add6de71f569a5251e71641e1e56cc
7
- data.tar.gz: 7de2306a64022969b441d747fb9e3424d1ef8ad48928bbe2a34938bd19845b6a347538b483c9a3db556bb4f5b84b6dbc6c5331213072e1ca4dd934646a7259eb
6
+ metadata.gz: 55fa6d66d7ef33b497a59b8d4443367005873d22997e1a752ed550edf10fa7cf664d671442d207149627e1d26f80efff450870052e3d89b2436e909dfdc8e6a3
7
+ data.tar.gz: 4e5812199673963f7615383018ee801c8360acfd23bc6e4737d1aa86c10f72f9f00b86cfa48076505aa4f8acec7d08393fdd816760c613d32e78c5c344992d1d
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.10.0 (28-Feb-20)
4
+
5
+ * Added methods to [regenerate webhook secret](https://lokalise.com/api2docs/curl/#transition-regenerate-a-webhook-secret-patch):
6
+ + `@client.regenerate_webhook_secret(project_id, webhook_id)`
7
+ + `webhook.regenerate_secret`
8
+ * API base URL is now `https://api.lokalise.com/api2/` instead of `https://api.lokalise.co/api2/`
9
+
3
10
  ## 2.9.0.1 (21-Jan-20)
4
11
 
5
12
  * Make JSON dependency version less strict
data/README.md CHANGED
@@ -1669,6 +1669,25 @@ webhook = @client.webhook(project_id, webhook_id)
1669
1669
  webhook.destroy
1670
1670
  ```
1671
1671
 
1672
+ #### Regenerate webhook secret
1673
+
1674
+ [Doc](https://lokalise.com/api2docs/curl/#transition-regenerate-a-webhook-secret-patch)
1675
+
1676
+ ```ruby
1677
+ @client.regenerate_webhook_secret(project_id, webhook_id) # Input:
1678
+ ## project_id (string, required)
1679
+ ## webhook_id (string or integer, required)
1680
+ # Output:
1681
+ ## Hash containing `project_id` and new `secret`
1682
+ ```
1683
+
1684
+ Alternatively:
1685
+
1686
+ ```ruby
1687
+ webhook = @client.webhook(project_id, webhook_id)
1688
+ webhook.regenerate_secret
1689
+ ```
1690
+
1672
1691
  ## Additional Info
1673
1692
 
1674
1693
  ### Customizing Request
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lokalise
4
4
  module Connection
5
- BASE_URL = 'https://api.lokalise.co/api2/'
5
+ BASE_URL = 'https://api.lokalise.com/api2/'
6
6
 
7
7
  def connection(client)
8
8
  options = {
@@ -29,6 +29,13 @@ module Lokalise
29
29
  )
30
30
  end
31
31
 
32
+ def patch(path, client, params = {})
33
+ respond_with(
34
+ connection(client).patch(prepare(path), params.any? ? custom_dump(params) : nil),
35
+ client
36
+ )
37
+ end
38
+
32
39
  def delete(path, client, params = {})
33
40
  respond_with(
34
41
  # Rubocop tries to replace `delete` with `gsub` but that's a different method here!
@@ -5,10 +5,18 @@ module Lokalise
5
5
  class Webhook < Base
6
6
  supports :update, :destroy
7
7
 
8
+ def regenerate_secret
9
+ self.class.regenerate_secret @client, @path + '/secret/regenerate'
10
+ end
11
+
8
12
  class << self
9
- def endpoint(project_id, webhook_id = nil)
13
+ def regenerate_secret(client, path, *_args)
14
+ patch(path, client)['content']
15
+ end
16
+
17
+ def endpoint(project_id, webhook_id = nil, *actions)
10
18
  path_from projects: project_id,
11
- webhooks: webhook_id
19
+ webhooks: [webhook_id, *actions]
12
20
  end
13
21
  end
14
22
  end
@@ -52,5 +52,16 @@ module Lokalise
52
52
  def destroy_webhook(project_id, webhook_id)
53
53
  c_r Lokalise::Resources::Webhook, :destroy, [project_id, webhook_id]
54
54
  end
55
+
56
+ # Regenerates secret for the given webhook
57
+ #
58
+ # @see https://lokalise.com/api2docs/curl/#transition-regenerate-a-webhook-secret-patch
59
+ # @return [Hash]
60
+ # @param project_id [String]
61
+ # @param webhook_id [String, Integer]
62
+ def regenerate_webhook_secret(project_id, webhook_id)
63
+ c_r Lokalise::Resources::Webhook, :regenerate_secret,
64
+ [project_id, webhook_id, 'secret', 'regenerate']
65
+ end
55
66
  end
56
67
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lokalise
4
- VERSION = '2.9.0.1'
4
+ VERSION = '2.10.0'
5
5
  end
@@ -4,6 +4,7 @@ RSpec.describe Lokalise::Client do
4
4
  let(:project_id) { '803826145ba90b42d5d860.46800099' }
5
5
  let(:webhook_id) { 'c7eb7e6e3c2fb2b26d0b64d0de083a5a71675b3d' }
6
6
  let(:new_webhook_id) { 'b345ccc6499920c490e8f4fe9487b1378dbf1dbf' }
7
+ let(:serious_webhook_id) { '795565582e5ab15a59bb68156c7e2e9eaa1e8d1a' }
7
8
 
8
9
  describe '#webhooks' do
9
10
  it 'returns all webhooks' do
@@ -73,4 +74,40 @@ RSpec.describe Lokalise::Client do
73
74
  expect(response['project_id']).to eq(project_id)
74
75
  expect(response['webhook_deleted']).to eq(true)
75
76
  end
77
+
78
+ specify '#regenerate_webhook_secret' do
79
+ response = VCR.use_cassette('regenerate_webhook_secret') do
80
+ test_client.regenerate_webhook_secret project_id,
81
+ serious_webhook_id
82
+ end
83
+
84
+ expect(response['project_id']).to eq(project_id)
85
+ expect(response['secret']).not_to be_nil
86
+ end
87
+
88
+ context 'when webhook chained methods are used' do
89
+ it 'supports regenerate_webhook_secret' do
90
+ webhook = VCR.use_cassette('webhook_2') do
91
+ test_client.webhook project_id, serious_webhook_id
92
+ end
93
+
94
+ expect(webhook.webhook_id).to eq(serious_webhook_id)
95
+
96
+ response = VCR.use_cassette('regenerate_webhook_secret_2') do
97
+ webhook.regenerate_secret
98
+ end
99
+
100
+ expect(response['project_id']).to eq(project_id)
101
+ expect(response['secret']).not_to be_nil
102
+ end
103
+
104
+ it 'supports update and destroy' do
105
+ webhook = VCR.use_cassette('webhook_2') do
106
+ test_client.webhook project_id, serious_webhook_id
107
+ end
108
+
109
+ expect(webhook).to respond_to(:update)
110
+ expect(webhook).to respond_to(:destroy)
111
+ end
112
+ end
76
113
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lokalise-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0.1
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Bodrov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-21 00:00:00.000000000 Z
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable