octobat 2.0.25 → 2.0.26

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: 8c0554602d9f2b3795ebeb50fc235d1b3fdf1da9a01222153d15a3d2167a35b0
4
- data.tar.gz: dcf455738a4a19b5ed27028854b1bc344c7ac37efe8ceb63b92239827e54bdcc
3
+ metadata.gz: 330a8b81687cd079b059ebd5b768f80152d7f93ce97f255637b8fc1bd45d681f
4
+ data.tar.gz: 3647619a56554df275ec31fc6c14aeed477b260d2bb00608ee23418cd0ac78e5
5
5
  SHA512:
6
- metadata.gz: 4f760778d1fa6800a687b9eb690688f19809d8fbfaf593648a832defa02e983a0d3da1e7e64b86f6d0e24d9767446cb8cb1cd3f5027215d498a15493cd1d434e
7
- data.tar.gz: 43e40f5f2152c0d8da4d807cf29738fa296107f4b68eace16f713d94ec79ab67992b850b88d15bcbd42cad3d1962a808044e273d248a49de277a7f66f682ed3d
6
+ metadata.gz: 96a550fd8e9c24cfe1446ebfe3ebe3ae5a87b4d1adcac7c7575e3e68b7f3cf370a705d00e8f60d835c0108c8f7b397ffdfd2c45c0608be1285a18614d893068d
7
+ data.tar.gz: 3c08c868d74a6f9bd4b1fb0314def0745d8d5510054fb2f453e86831124db8992111af23a34b5db574c79041ffbf7c3b914a18718610bbd5e85968eafc58d2d9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- octobat (2.0.25)
4
+ octobat (2.0.26)
5
5
  rest-client (>= 1.4, < 4.0)
6
6
 
7
7
  GEM
@@ -14,7 +14,7 @@ GEM
14
14
  domain_name (~> 0.5)
15
15
  mime-types (3.3.1)
16
16
  mime-types-data (~> 3.2015)
17
- mime-types-data (3.2020.1104)
17
+ mime-types-data (3.2021.0225)
18
18
  netrc (0.11.0)
19
19
  rest-client (2.1.0)
20
20
  http-accept (>= 1.7.0, < 2.0)
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 2.0.26 2021-05-31
2
+ * 2 major enhancements:
3
+ * Add support for Octobat Plaza endpoints
4
+ * Add persistence of the octobat_account header through requests
5
+
1
6
  === 2.0.25 2020-12-24
2
7
  * 2 major enhancements:
3
8
  * Add support for Subscription object
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.25
1
+ 2.0.26
data/lib/octobat.rb CHANGED
@@ -60,7 +60,14 @@ require 'octobat/usage_item'
60
60
 
61
61
  require 'octobat/file_upload'
62
62
  require 'octobat/file_link'
63
+
63
64
  require 'octobat/beanie/session'
65
+
66
+ require 'octobat/plaza/account'
67
+ require 'octobat/plaza/capability'
68
+ require 'octobat/plaza/country_spec'
69
+
70
+
64
71
  require 'octobat/reporting/report_type'
65
72
  require 'octobat/reporting/report_run'
66
73
 
@@ -24,8 +24,10 @@ module Octobat
24
24
  @api_key = opts[:api_key]
25
25
 
26
26
  @retrieve_options.merge!(opts.clone).delete(:api_key)
27
+
27
28
  @headers['Octobat-Version'] = @retrieve_options.delete('Octobat-Version') if @retrieve_options.has_key?('Octobat-Version')
28
-
29
+ @headers[:octobat_account] = @retrieve_options.delete(:octobat_account) if @retrieve_options.has_key?(:octobat_account)
30
+
29
31
  @values = {}
30
32
  # This really belongs in APIResource, but not putting it there allows us
31
33
  # to have a unified inspect method
@@ -0,0 +1,39 @@
1
+ module Octobat
2
+ module Plaza
3
+ class Account < Octobat::APIResource
4
+ extend Octobat::APIOperations::List
5
+ include Octobat::APIOperations::Create
6
+ include Octobat::APIOperations::Update
7
+
8
+ def self.url
9
+ '/plaza/accounts'
10
+ end
11
+
12
+ def activate(params = {}, opts = {})
13
+ response, api_key = Octobat.request(:patch, activate_url, @api_key, params, opts)
14
+ refresh_from(response, api_key)
15
+ end
16
+
17
+ def deactivate(params = {}, opts = {})
18
+ response, api_key = Octobat.request(:patch, deactivate_url, @api_key, params, opts)
19
+ refresh_from(response, api_key)
20
+ end
21
+
22
+ def list_capabilities(params = {}, opts = {})
23
+ Capability.list(params.merge({ :account => id }), {api_key: @api_key}.merge(opts))
24
+ end
25
+
26
+
27
+ private
28
+ def activate_url
29
+ url + '/activate'
30
+ end
31
+
32
+ def deactivate_url
33
+ url + '/deactivate'
34
+ end
35
+
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,56 @@
1
+ module Octobat
2
+ module Plaza
3
+ class Capability < Octobat::APIResource
4
+ extend Octobat::APIOperations::List
5
+
6
+ def url
7
+ !parent_obj.nil? ? parentize_url : super
8
+ end
9
+
10
+ def ask(params = {}, opts = {})
11
+ response, api_key = Octobat.request(:patch, ask_url, @api_key, params, opts)
12
+ refresh_from(response, api_key)
13
+ end
14
+
15
+ def save_url
16
+ if self[:id] == nil && self.class.respond_to?(:create)
17
+ self.relative_save_url
18
+ else
19
+ url
20
+ end
21
+ end
22
+
23
+
24
+ def parentize_url
25
+ if parent_obj.include?(:account)
26
+ "#{Account.url}/#{CGI.escape(parent_obj[:account])}/capabilities/#{CGI.escape(id)}"
27
+ else
28
+ url
29
+ end
30
+ end
31
+
32
+
33
+
34
+ def relative_save_url
35
+ if self[:account]
36
+ "#{Account.url}/#{CGI.escape(self[:account])}/capabilities"
37
+ end
38
+ end
39
+
40
+ def ask_url
41
+ "#{parentize_url}/request"
42
+ end
43
+
44
+ def self.url
45
+ if @parent_resource.include?(:account)
46
+ "#{Account.url}/#{CGI.escape(@parent_resource[:account])}/capabilities"
47
+ end
48
+ end
49
+
50
+ def self.set_parent_resource(filters)
51
+ @parent_resource = filters.select{|k, v| [:account].include?(k)}
52
+ end
53
+
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,12 @@
1
+ module Octobat
2
+ module Plaza
3
+ class CountrySpec < Octobat::APIResource
4
+ extend Octobat::APIOperations::List
5
+
6
+ def self.url
7
+ '/plaza/country_specs'
8
+ end
9
+
10
+ end
11
+ end
12
+ end
data/lib/octobat/util.rb CHANGED
@@ -75,6 +75,9 @@ module Octobat
75
75
  'file' => FileUpload,
76
76
  'file_link' => FileLink,
77
77
  'beanie.session' => Beanie::Session,
78
+ 'plaza.account' => Plaza::Account,
79
+ 'plaza.capability' => Plaza::Capability,
80
+ 'plaza.country_spec' => Plaza::CountrySpec,
78
81
  'reporting.report_type' => Reporting::ReportType,
79
82
  'reporting.report_run' => Reporting::ReportRun
80
83
  }
@@ -1,3 +1,3 @@
1
1
  module Octobat
2
- VERSION = '2.0.25'
2
+ VERSION = '2.0.26'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octobat
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.25
4
+ version: 2.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gaultier Laperche
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-24 00:00:00.000000000 Z
11
+ date: 2021-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -94,6 +94,9 @@ files:
94
94
  - lib/octobat/payment_recipient_reference.rb
95
95
  - lib/octobat/payment_source.rb
96
96
  - lib/octobat/payout.rb
97
+ - lib/octobat/plaza/account.rb
98
+ - lib/octobat/plaza/capability.rb
99
+ - lib/octobat/plaza/country_spec.rb
97
100
  - lib/octobat/product.rb
98
101
  - lib/octobat/proforma_invoice.rb
99
102
  - lib/octobat/purchase_item.rb