adobe_doc_api 0.1.2 → 0.1.3

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: 5d1e60f6687db22347aa8a8d772e066716ff6b9c9d5d9065ab0395543ab8808e
4
- data.tar.gz: 40f43095bb7fb02dd9a8724941c823c3870965a40b313f9e580e9d919dc13def
3
+ metadata.gz: 4e5a77582f1fc5d80a10d049be384c0abf2dbe2b4206522128e536a8787517de
4
+ data.tar.gz: 5373eb84624217386db5663be8b8c829dcd9b98128a5a634c9467185ce3e6f3d
5
5
  SHA512:
6
- metadata.gz: d47936fe2d22f56b0268c1e60019847a45b63ff35c5dac178e43fe5e597e68ccb9c3be16c293101410ccdc94dc9b4522c891852792d84a42bcd67c3b32a44288
7
- data.tar.gz: 2c479317760c7ae45aa6dfd31ac6606cf71e7db98107cd9e1bbd308e19a017816aed99441420492ff400959f24fc4386285b26834c481872cc285f11f3f39b18
6
+ metadata.gz: 9b0b0dd6eff1e19d986ef5e52e0b2409b88ecba9bac484948ed7366a485b062f94c7c11f81160735f714e08c5a24a38b6baca8cbebd15148c9562e8b360f7fdc
7
+ data.tar.gz: aa00f4f6446199a46dab1b0101cbc3acd71ab44692375b83695e7062eccacab12b549298528a80f45e9c80b46ddc42217339a36d7d612aa91c39c3e86070d71c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.3] - 2021-12-30
4
+ - Added ability to configure AdobeDocApi to provide better customization
5
+
3
6
  ## [0.1.0] - 2021-12-28
4
7
 
5
8
  - Initial release
data/README.md CHANGED
@@ -18,13 +18,16 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install adobe_doc_api
20
20
 
21
- ## Recommended ENV variables
22
- *Client.new will fallback to use these variables if they are not passed in setup
21
+ ## Configuration
22
+ * Configuration can be overridden if you need by passing the values to AdobeDocApi::Client.new
23
23
  ```ruby
24
- ENV['adobe_org_id']
25
- ENV['adobe_tech_account_id']
26
- ENV['adobe_client_id']
27
- ENV['adobe_client_secret']
24
+ AdobeDocApi.configure do |config|
25
+ config.client_id = nil
26
+ config.client_secret = nil
27
+ config.org_id = nil
28
+ config.tech_account_id = nil
29
+ config.private_key_path = nil
30
+ end
28
31
  ```
29
32
 
30
33
  ## Usage
@@ -35,11 +38,13 @@ template_path = "../full_path_to/disclosure.docx"
35
38
  output_path = "../full_path_to_output/output.docx"
36
39
  json_data = { 'DocTag': 'Value', 'DocTag2': 'Value2'}
37
40
 
38
- client = AdobeDocApi::Client.new(private_key: key_path)
39
- # Without ENV variables set
41
+ client = AdobeDocApi::Client.new
42
+
43
+ # Without configuration you must pass these values
40
44
  # client = AdobeDocApi::Client.new(private_key: key_path, client_id: ENV['adobe_client_id'], client_secret: ENV['adobe_client_secret']org_id: ENV['adobe_org_id'], tech_account_id: ENV['adobe_tech_account_id'], access_token: nil)
41
45
 
42
46
  client.submit(json: json_data, template: template_path, output: output_path)
47
+ # returns true or false if file was saved to output_path
43
48
  ```
44
49
 
45
50
  ## Todo
@@ -10,16 +10,17 @@ module AdobeDocApi
10
10
 
11
11
  attr_reader :access_token, :location_url, :raw_response, :client_id, :client_secret, :org_id, :tech_account_id
12
12
 
13
- def initialize(private_key:, client_id: ENV["adobe_client_id"], client_secret: ENV["adobe_client_secret"], org_id: ENV["adobe_org_id"], tech_account_id: ENV["adobe_tech_account_id"], access_token: nil)
13
+ def initialize(private_key: nil, client_id: nil, client_secret: nil, org_id: nil, tech_account_id: nil, access_token: nil)
14
14
  # TODO Need to validate if any params are missing and return error
15
- @client_id = client_id
16
- @client_secret = client_secret
17
- @org_id = org_id
18
- @tech_account_id = tech_account_id
15
+ @client_id = client_id || AdobeDocApi.configuration.client_id
16
+ @client_secret = client_secret || AdobeDocApi.configuration.client_secret
17
+ @org_id = org_id || AdobeDocApi.configuration.org_id
18
+ @tech_account_id = tech_account_id || AdobeDocApi.configuration.tech_account_id
19
+ @private_key_path = private_key || AdobeDocApi.configuration.private_key_path
19
20
  @location_url = nil
20
21
  @output_file_path = nil
21
22
  @raw_response = nil
22
- @access_token = access_token || get_access_token(private_key)
23
+ @access_token = access_token || get_access_token(@private_key_path)
23
24
  end
24
25
 
25
26
  def get_access_token(private_key)
@@ -45,7 +46,6 @@ module AdobeDocApi
45
46
  end
46
47
 
47
48
  return response.body["access_token"]
48
-
49
49
  end
50
50
 
51
51
  def submit(json:, template:, output:)
@@ -0,0 +1,13 @@
1
+ module AdobeDocApi
2
+ class Configuration
3
+ attr_accessor :client_id, :client_secret, :org_id, :tech_account_id, :private_key_path
4
+
5
+ def initialize
6
+ @client_id = nil
7
+ @client_sercret = nil
8
+ @org_id = nil
9
+ @tech_account_id = nil
10
+ @private_key_path = nil
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AdobeDocApi
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/adobe_doc_api.rb CHANGED
@@ -1,10 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "adobe_doc_api/version"
4
+ require "adobe_doc_api/configuration"
4
5
 
5
6
  module AdobeDocApi
6
7
  autoload :Client, "adobe_doc_api/client"
7
8
  autoload :Error, "adobe_doc_api/error"
8
9
 
9
- # Your code goes here...
10
+ class << self
11
+ attr_accessor :configuration
12
+ end
13
+
14
+ def self.configuration
15
+ @configuration ||= Configuration.new
16
+ end
17
+
18
+ def self.reset
19
+ @configuration = Configuration.new
20
+ end
21
+
22
+ def self.configure
23
+ yield(configuration)
24
+ end
25
+
10
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adobe_doc_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Sonnier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-29 00:00:00.000000000 Z
11
+ date: 2021-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -83,6 +83,7 @@ files:
83
83
  - bin/setup
84
84
  - lib/adobe_doc_api.rb
85
85
  - lib/adobe_doc_api/client.rb
86
+ - lib/adobe_doc_api/configuration.rb
86
87
  - lib/adobe_doc_api/error.rb
87
88
  - lib/adobe_doc_api/version.rb
88
89
  homepage: https://github.com/c-sonnier/adobe_doc_api