panda_doc 0.3.2 → 0.4.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
  SHA1:
3
- metadata.gz: b975a1fcc43d92ed3f46914b421d874673f440a3
4
- data.tar.gz: 8ed163be41e3cad83d7ed887606e0a4b743e47aa
3
+ metadata.gz: 5de18dd847aacd923cd904d156707fc38c75fc46
4
+ data.tar.gz: 7484054a9220ccbf5b2aff13d8205e2212f78d4b
5
5
  SHA512:
6
- metadata.gz: 9e5684b13155e8ec17a5f2d4591995dc3a71708af1b990de6c8c1ab805fa084a67c818b01f0000c168b7166cf85a0ca81de5a2fc8ebb8c56ac90ed745301c0a3
7
- data.tar.gz: ce967a20524e3a8271f80eb46828830ed143f09ce2f8bdd9b33e61c8a1594474d8bcc3d7c313301b7429048331f54aaabb9e1a758cc1982527a6ef2aeaa1abe0
6
+ metadata.gz: f6c816f0ff6a3ab76b697777d47b0366ae328896ae0314c0d34c70fc00ce98e42128a7f86af819d0e893679cdceb4b15df7caf0f6dce204089af13f22c4529da
7
+ data.tar.gz: fb01545fd5dfba46f80c15f7614ad9d4024254762b020b5fe20fb25deb1074117fafbe98b0e4641c0202441f1df9fc6d2a41bebb11c1b4d212bb71496fd409d6
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.4.0][] (2016-05-19)
8
+
9
+ New:
10
+
11
+ - Add ability to create a document from attached pdf file.
12
+
13
+ ```ruby
14
+ file = UploadIO.new("/path/to/file.pdf", "application/pdf")
15
+
16
+ PandaDoc::Document.create(
17
+ file: file,
18
+ name: "Sample",
19
+ ...
20
+ )
21
+ ```
22
+
7
23
  ## [0.3.2][] (2016-04-15)
8
24
 
9
25
  New:
@@ -86,7 +102,8 @@ Fixes:
86
102
 
87
103
  - Initial release
88
104
 
89
- [Unreleased]: https://github.com/opti/panda_doc/compare/v0.3.2...HEAD
105
+ [Unreleased]: https://github.com/opti/panda_doc/compare/v0.4.0...HEAD
106
+ [0.4.0]: https://github.com/opti/panda_doc/compare/v0.3.2...v0.4.0
90
107
  [0.3.2]: https://github.com/opti/panda_doc/compare/v0.3.1...v0.3.2
91
108
  [0.3.1]: https://github.com/opti/panda_doc/compare/v0.3.0...v0.3.1
92
109
  [0.3.0]: https://github.com/opti/panda_doc/compare/v0.2.0...v0.3.0
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem "bundler", "~> 1.11"
7
- gem "rake", "~> 10.0"
7
+ gem "rake", ">= 10.0"
8
8
  gem "rspec", "~> 3.4"
9
9
  gem "byebug"
10
10
 
data/README.md CHANGED
@@ -67,6 +67,31 @@ document.created_at # => #<DateTime: 2016-02-03T14:56:21-08:00>
67
67
  document.updated_at # => #<DateTime: 2016-02-03T14:56:21-08:00>
68
68
  ```
69
69
 
70
+ #### Creating a document from attached file
71
+
72
+ ```ruby
73
+ file = UploadIO.new("/path/to/file.pdf", "application/pdf")
74
+
75
+ document = PandaDoc::Document.create(
76
+ name: "Sample Document",
77
+ file: file,
78
+ recipients: [
79
+ {
80
+ email: "john.appleseed@yourdomain.com",
81
+ first_name: "John",
82
+ last_name: "Appleseed",
83
+ role: "Signer",
84
+ default: false
85
+ }
86
+ ],
87
+ fields: {
88
+ field_id: {
89
+ title: "Field 1"
90
+ }
91
+ }
92
+ )
93
+ ```
94
+
70
95
  #### Creating a document from a template
71
96
 
72
97
  ```ruby
@@ -1,9 +1,15 @@
1
+ require "json"
2
+
1
3
  module PandaDoc
2
4
  class ApiClient
3
5
 
4
6
  class << self
5
7
  def request(verb, path, **data)
6
- new.public_send(verb, path, data)
8
+ if file = data.delete(:file)
9
+ data = { file: file, data: JSON.generate(data) }
10
+ end
11
+
12
+ new(multipart: !!file).public_send(verb, path, data)
7
13
  end
8
14
  end
9
15
 
@@ -12,14 +18,22 @@ module PandaDoc
12
18
  attr_reader :url_prefix
13
19
  private :url_prefix
14
20
 
15
- def initialize
21
+ def initialize(multipart: false)
16
22
  @url_prefix = "/public/v1"
17
23
  @connection = Faraday.new(PandaDoc.configuration.endpoint) do |conn|
18
24
  conn.authorization :Bearer, PandaDoc.configuration.access_token
19
- conn.request :json
25
+
26
+ if multipart
27
+ conn.request :multipart
28
+ conn.request :url_encoded
29
+ else
30
+ conn.request :json
31
+ end
32
+
20
33
  if PandaDoc.configuration.logger
21
34
  conn.response :logger, PandaDoc.configuration.logger, bodies: true
22
35
  end
36
+
23
37
  conn.response :json, content_type: /\bjson$/
24
38
  conn.adapter Faraday.default_adapter
25
39
  end
@@ -1,3 +1,3 @@
1
1
  module PandaDoc
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Pstyga
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-15 00:00:00.000000000 Z
11
+ date: 2016-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday