panda_doc 0.7.0 → 0.9.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8849ee8f7c8311a7eb442ff4c1b059c94a6ec87fb039a23cc74b1dd06c0c6873
4
- data.tar.gz: 4563201e0b177abf440381dc8f06ccf876603f9c9c45d34a71d54786ae615144
3
+ metadata.gz: e189a237a7930954bc8a7b2550037a49f8d371411aee0abbebd6463eff3c1806
4
+ data.tar.gz: 589a8c3207e8eed78061afa341e052287b77f278985047b32b924648cd1f353d
5
5
  SHA512:
6
- metadata.gz: 74541a952ad1c7f327e220dd197ce0213fd2d9de697fb5e2743f46b72b5a2e1df94e7c801cf5b833406fac61751de1cbc4b2af643b7daa3b4c10f69e25cd34fa
7
- data.tar.gz: 04ff0e440faac7e29d5f8b6bfa9ffe9f8bf31f0399eeeab18f6cc9940be1b482d74c47915c21d2b40b396328fca5bce3c1c37f172dcb13adfb1f97a55aece404
6
+ metadata.gz: 5e213cabf79b1661781d05a7038462022c7853328399dcf128bef59fdce266650f4e5a85db0850241287a8a3e105daadc31fbe185cc0d4d0e53a518f48735be0
7
+ data.tar.gz: 5b3aba148b0e22c1823bf8d8e6b9536090a1b9c96b9449c6f64316cbb40eea021915329d0686c5cc910beaa6471b04a6708d4268134696dd30b367b79d89cf1e
@@ -13,15 +13,15 @@ jobs:
13
13
  fail-fast: false
14
14
  matrix:
15
15
  ruby:
16
+ - '3.3'
16
17
  - '3.2'
17
18
  - '3.1'
18
19
  - '3.0'
19
- - '2.7'
20
20
  include:
21
- - ruby: '3.2'
21
+ - ruby: '3.3'
22
22
  coverage: '1'
23
23
  steps:
24
- - uses: actions/checkout@v3
24
+ - uses: actions/checkout@v4
25
25
  with:
26
26
  submodules: true
27
27
  - name: Setup Ruby
@@ -31,7 +31,7 @@ jobs:
31
31
  - name: Update rubygems
32
32
  run: |
33
33
  gem update --system
34
- - uses: actions/cache@v3
34
+ - uses: actions/cache@v4
35
35
  with:
36
36
  path: vendor/bundle
37
37
  key: bundle-use-ruby-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
@@ -47,7 +47,7 @@ jobs:
47
47
  run: |
48
48
  bundle exec rake spec
49
49
  - name: Publish code coverage
50
- if: ${{ matrix.coverage == '1' && github.actor != 'dependabot[bot]' }}
51
- uses: paambaati/codeclimate-action@v3.1.1
50
+ if: ${{ matrix.coverage == '1' && github.actor != 'dependabot[bot]' && github.ref_name == 'main' }}
51
+ uses: paambaati/codeclimate-action@v8
52
52
  env:
53
53
  CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.2
1
+ 3.3.5
data/CHANGELOG.md CHANGED
@@ -4,6 +4,25 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.9.0][] (2024-07-12)
8
+
9
+ New:
10
+
11
+ - Add `Document.list` for [List Documents](https://developers.pandadoc.com/reference/list-documents) endpoint.
12
+ ```ruby
13
+ list = PandaDoc::Document.list
14
+ list.documents.first.name
15
+ => "Sample Name"
16
+ ```
17
+
18
+ ## [0.8.0][] (2024-07-12)
19
+
20
+ New:
21
+
22
+ - Optional `metadata` field which can be used to store arbitrary data (by @andrewvy)
23
+ - `Document.move_to_draft` -> POST /documents/{id}/draft/ (by @andrewvy)
24
+ - `Document.update` -> PATCH /documents/{id}/ (by @andrewvy)
25
+
7
26
  ## [0.7.0][] (2023-06-07)
8
27
 
9
28
  New:
@@ -182,7 +201,6 @@ New:
182
201
  response.error.detail => {"fields"=>["Field 'foo' does not exist."]}
183
202
  ```
184
203
 
185
-
186
204
  ## [0.0.2][] (2016-02-13)
187
205
 
188
206
  New:
@@ -204,7 +222,9 @@ Fixes:
204
222
 
205
223
  - Initial release
206
224
 
207
- [Unreleased]: https://github.com/opti/panda_doc/compare/v0.7.0...HEAD
225
+ [Unreleased]: https://github.com/opti/panda_doc/compare/v0.9.0...HEAD
226
+ [0.9.0]: https://github.com/opti/panda_doc/compare/v0.8.0...v0.9.0
227
+ [0.8.0]: https://github.com/opti/panda_doc/compare/v0.7.0...v0.8.0
208
228
  [0.7.0]: https://github.com/opti/panda_doc/compare/v0.6.0...v0.7.0
209
229
  [0.6.0]: https://github.com/opti/panda_doc/compare/v0.5.3...v0.6.0
210
230
  [0.5.3]: https://github.com/opti/panda_doc/compare/v0.5.2...v0.5.3
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ gemspec
5
5
 
6
6
  gem "bundler"
7
7
  gem "rake", ">= 10.0"
8
- gem "rspec", "~> 3.12"
8
+ gem "rspec", "~> 3.13"
9
9
  gem "byebug"
10
10
 
11
11
  group :test do
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- panda_doc (0.7.0)
4
+ panda_doc (0.9.0)
5
5
  dry-configurable
6
6
  dry-struct
7
7
  faraday (>= 2.0.1, < 3.0)
@@ -10,17 +10,19 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
+ bigdecimal (3.1.8)
13
14
  byebug (11.1.3)
14
- concurrent-ruby (1.2.2)
15
- diff-lcs (1.5.0)
16
- docile (1.4.0)
17
- dry-configurable (1.0.1)
15
+ concurrent-ruby (1.3.4)
16
+ diff-lcs (1.5.1)
17
+ docile (1.4.1)
18
+ dry-configurable (1.2.0)
18
19
  dry-core (~> 1.0, < 2)
19
20
  zeitwerk (~> 2.6)
20
- dry-core (1.0.0)
21
+ dry-core (1.0.2)
21
22
  concurrent-ruby (~> 1.0)
23
+ logger
22
24
  zeitwerk (~> 2.6)
23
- dry-inflector (1.0.0)
25
+ dry-inflector (1.1.0)
24
26
  dry-logic (1.5.0)
25
27
  concurrent-ruby (~> 1.0)
26
28
  dry-core (~> 1.0, < 2)
@@ -30,42 +32,49 @@ GEM
30
32
  dry-types (>= 1.7, < 2)
31
33
  ice_nine (~> 0.11)
32
34
  zeitwerk (~> 2.6)
33
- dry-types (1.7.1)
35
+ dry-types (1.7.2)
36
+ bigdecimal (~> 3.0)
34
37
  concurrent-ruby (~> 1.0)
35
38
  dry-core (~> 1.0)
36
39
  dry-inflector (~> 1.0)
37
40
  dry-logic (~> 1.4)
38
41
  zeitwerk (~> 2.6)
39
- faraday (2.7.6)
40
- faraday-net_http (>= 2.0, < 3.1)
41
- ruby2_keywords (>= 0.0.4)
42
+ faraday (2.12.0)
43
+ faraday-net_http (>= 2.0, < 3.4)
44
+ json
45
+ logger
42
46
  faraday-multipart (1.0.4)
43
47
  multipart-post (~> 2)
44
- faraday-net_http (3.0.2)
48
+ faraday-net_http (3.3.0)
49
+ net-http
45
50
  ice_nine (0.11.2)
46
- multipart-post (2.3.0)
47
- rake (13.0.6)
48
- rspec (3.12.0)
49
- rspec-core (~> 3.12.0)
50
- rspec-expectations (~> 3.12.0)
51
- rspec-mocks (~> 3.12.0)
52
- rspec-core (3.12.2)
53
- rspec-support (~> 3.12.0)
54
- rspec-expectations (3.12.3)
51
+ json (2.7.5)
52
+ logger (1.6.1)
53
+ multipart-post (2.4.1)
54
+ net-http (0.4.1)
55
+ uri
56
+ rake (13.2.1)
57
+ rspec (3.13.0)
58
+ rspec-core (~> 3.13.0)
59
+ rspec-expectations (~> 3.13.0)
60
+ rspec-mocks (~> 3.13.0)
61
+ rspec-core (3.13.2)
62
+ rspec-support (~> 3.13.0)
63
+ rspec-expectations (3.13.3)
55
64
  diff-lcs (>= 1.2.0, < 2.0)
56
- rspec-support (~> 3.12.0)
57
- rspec-mocks (3.12.5)
65
+ rspec-support (~> 3.13.0)
66
+ rspec-mocks (3.13.2)
58
67
  diff-lcs (>= 1.2.0, < 2.0)
59
- rspec-support (~> 3.12.0)
60
- rspec-support (3.12.0)
61
- ruby2_keywords (0.0.5)
68
+ rspec-support (~> 3.13.0)
69
+ rspec-support (3.13.1)
62
70
  simplecov (0.22.0)
63
71
  docile (~> 1.1)
64
72
  simplecov-html (~> 0.11)
65
73
  simplecov_json_formatter (~> 0.1)
66
- simplecov-html (0.12.3)
74
+ simplecov-html (0.13.1)
67
75
  simplecov_json_formatter (0.1.4)
68
- zeitwerk (2.6.8)
76
+ uri (0.13.1)
77
+ zeitwerk (2.7.1)
69
78
 
70
79
  PLATFORMS
71
80
  ruby
@@ -75,8 +84,8 @@ DEPENDENCIES
75
84
  byebug
76
85
  panda_doc!
77
86
  rake (>= 10.0)
78
- rspec (~> 3.12)
87
+ rspec (~> 3.13)
79
88
  simplecov (~> 0.22.0)
80
89
 
81
90
  BUNDLED WITH
82
- 2.4.13
91
+ 2.5.22
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PandaDoc
4
+ # This class is responsible for making HTTP requests to the PandaDoc API.
4
5
  class ApiClient
5
-
6
6
  class << self
7
7
  def request(verb, path, data = {})
8
8
  if file = data.delete(:file)
@@ -13,9 +13,8 @@ module PandaDoc
13
13
  end
14
14
  end
15
15
 
16
- attr_reader :connection
16
+ attr_reader :connection, :url_prefix
17
17
 
18
- attr_reader :url_prefix
19
18
  private :url_prefix
20
19
 
21
20
  def initialize(multipart: false)
@@ -51,6 +50,10 @@ module PandaDoc
51
50
  connection.get(normalized_path(path), **data)
52
51
  end
53
52
 
53
+ def patch(path, data = {})
54
+ connection.patch(normalized_path(path), **data)
55
+ end
56
+
54
57
  private
55
58
 
56
59
  def normalized_path(path)
@@ -4,10 +4,25 @@ module PandaDoc
4
4
  module Document
5
5
  extend self
6
6
 
7
+ # @param options [Hash]
8
+ def list(**options)
9
+ respond(
10
+ ApiClient.request(:get, "/documents", **options),
11
+ type: :documents_list
12
+ )
13
+ end
14
+
7
15
  def create(data)
8
16
  respond(ApiClient.request(:post, "/documents", **data))
9
17
  end
10
18
 
19
+ def update(uuid, **data)
20
+ respond(
21
+ ApiClient.request(:patch, "/documents/#{uuid}", **data),
22
+ type: :empty
23
+ )
24
+ end
25
+
11
26
  def send(uuid, **data)
12
27
  respond(ApiClient.request(:post, "/documents/#{uuid}/send", **data))
13
28
  end
@@ -20,6 +35,10 @@ module PandaDoc
20
35
  respond(ApiClient.request(:get, "/documents/#{uuid}/details"))
21
36
  end
22
37
 
38
+ def move_to_draft(uuid)
39
+ respond(ApiClient.request(:post, "/documents/#{uuid}/draft"))
40
+ end
41
+
23
42
  def session(uuid, **data)
24
43
  respond(
25
44
  ApiClient.request(:post, "/documents/#{uuid}/session", **data),
@@ -48,7 +67,7 @@ module PandaDoc
48
67
  end
49
68
 
50
69
  def failure(response)
51
- fail FailureResult.new(response) unless response.success?
70
+ raise FailureResult.new(response) unless response.success?
52
71
  end
53
72
  end
54
73
  end
@@ -15,6 +15,7 @@ module PandaDoc
15
15
 
16
16
  attribute? :tokens, Types::Array.of(Objects::Token)
17
17
  attribute? :fields, Types::Array.of(Objects::Field)
18
+ attribute? :metadata, Types::Hash
18
19
 
19
20
  alias_method :created_at, :date_created
20
21
  alias_method :updated_at, :date_modified
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PandaDoc
4
+ module Objects
5
+ # Represents a list of documents
6
+ class DocumentsList < Base
7
+ attribute :results, Types::Array.of(Objects::Document).default([].freeze)
8
+
9
+ alias_method :documents, :results
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PandaDoc
4
+ module Objects
5
+ class Empty
6
+ def initialize(_response_body)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -10,7 +10,7 @@ module PandaDoc
10
10
  end
11
11
 
12
12
  def initialize(type)
13
- @type = type.capitalize
13
+ @type = type.to_s.split('_').map(&:capitalize).join
14
14
  end
15
15
 
16
16
  def build
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PandaDoc
4
- VERSION = "0.7.0"
4
+ VERSION = "0.9.0"
5
5
  end
data/lib/panda_doc.rb CHANGED
@@ -21,6 +21,8 @@ require "panda_doc/objects/recipient"
21
21
  require "panda_doc/objects/token"
22
22
  require "panda_doc/objects/field"
23
23
  require "panda_doc/objects/document"
24
+ require "panda_doc/objects/documents_list"
25
+ require "panda_doc/objects/empty"
24
26
  require "panda_doc/objects/error"
25
27
  require "panda_doc/objects/session"
26
28
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panda_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Pstyga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-08 00:00:00.000000000 Z
11
+ date: 2024-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -109,6 +109,8 @@ files:
109
109
  - lib/panda_doc/failure_result.rb
110
110
  - lib/panda_doc/objects/base.rb
111
111
  - lib/panda_doc/objects/document.rb
112
+ - lib/panda_doc/objects/documents_list.rb
113
+ - lib/panda_doc/objects/empty.rb
112
114
  - lib/panda_doc/objects/error.rb
113
115
  - lib/panda_doc/objects/field.rb
114
116
  - lib/panda_doc/objects/recipient.rb
@@ -138,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
140
  - !ruby/object:Gem::Version
139
141
  version: '0'
140
142
  requirements: []
141
- rubygems_version: 3.4.13
143
+ rubygems_version: 3.5.22
142
144
  signing_key:
143
145
  specification_version: 4
144
146
  summary: Ruby wrapper for PandaDoc.com API