octobat 2.0.21 → 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: 39cb7d7e756a8a19162b43f02eddf46ff9ea2b0d3cf6cc7fa63c35e130393c36
4
- data.tar.gz: a199b92d99133f31b953ff6da3793e15ae0f29c0efd870e309a27a3ebb57352a
3
+ metadata.gz: 330a8b81687cd079b059ebd5b768f80152d7f93ce97f255637b8fc1bd45d681f
4
+ data.tar.gz: 3647619a56554df275ec31fc6c14aeed477b260d2bb00608ee23418cd0ac78e5
5
5
  SHA512:
6
- metadata.gz: '069f1946a31e8e0cc703a297bfccc4388ad8f1fd7709405f40f1e87578f76cd41f249c3611142a49ea94ff8c21673b971bcf9700dfba28815ce7a12b51727f94'
7
- data.tar.gz: f8146563ae30ef4bd58d134ad563c3faf783fdc5c7fdf37962803100b40a2753af56825570943a53dc8d42c439d1717d897a09d2be50fead8b6567173b33c498
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.21)
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,25 @@
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
+
6
+ === 2.0.25 2020-12-24
7
+ * 2 major enhancements:
8
+ * Add support for Subscription object
9
+ * Add support for UsageItem object
10
+
11
+ === 2.0.24 2020-12-15
12
+ * 1 minor enhancements:
13
+ * Add support for Invoice#mark_uncollectible endpoint
14
+
15
+ === 2.0.23 2020-12-03
16
+ * 1 minor enhancements:
17
+ * Add support for Invoice#set_payment_terms endpoint
18
+
19
+ === 2.0.22 2020-11-23
20
+ * 1 minor enhancements:
21
+ * Add support for CustomerBalanceTransaction object
22
+
1
23
  === 2.0.21 2020-11-12
2
24
  * 3 major enhancements:
3
25
  * Add support for Supplier object
@@ -13,7 +35,6 @@
13
35
  * Add { opts } param for all nested methods, so you can include headers such as the Connected Octobat Account ID in subrequests
14
36
  * Add support for CreditNote#cancel endpoint
15
37
 
16
-
17
38
  === 2.0.18 2020-05-25
18
39
  * 3 major enhancements:
19
40
  * Add support for multipart encoder (file upload)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.21
1
+ 2.0.26
data/lib/octobat.rb CHANGED
@@ -27,6 +27,7 @@ require 'octobat/list_object'
27
27
  require 'octobat/customer'
28
28
  require 'octobat/supplier'
29
29
  require 'octobat/transaction'
30
+ require 'octobat/customer_balance_transaction'
30
31
  require 'octobat/item'
31
32
  require 'octobat/purchase_item'
32
33
  require 'octobat/document'
@@ -54,10 +55,19 @@ require 'octobat/document_email_template'
54
55
  require 'octobat/exports_setting'
55
56
  require 'octobat/emails_setting'
56
57
  require 'octobat/tax_id'
58
+ require 'octobat/subscription'
59
+ require 'octobat/usage_item'
57
60
 
58
61
  require 'octobat/file_upload'
59
62
  require 'octobat/file_link'
63
+
60
64
  require 'octobat/beanie/session'
65
+
66
+ require 'octobat/plaza/account'
67
+ require 'octobat/plaza/capability'
68
+ require 'octobat/plaza/country_spec'
69
+
70
+
61
71
  require 'octobat/reporting/report_type'
62
72
  require 'octobat/reporting/report_run'
63
73
 
@@ -16,5 +16,10 @@ module Octobat
16
16
  def payment_sources(params = {}, opts = {})
17
17
  PaymentSource.list(params.merge({ :customer => id }), {api_key: @api_key}.merge(opts))
18
18
  end
19
+
20
+ def customer_balance_transactions(params = {}, opts = {})
21
+ CustomerBalanceTransaction.list(params.merge({ :customer => id }), {api_key: @api_key}.merge(opts))
22
+ end
23
+
19
24
  end
20
25
  end
@@ -0,0 +1,50 @@
1
+ module Octobat
2
+ class CustomerBalanceTransaction < APIResource
3
+ extend Octobat::APIOperations::List
4
+ include Octobat::APIOperations::Create
5
+
6
+
7
+ def url
8
+ !parent_obj.nil? ? parentize_url : super
9
+ end
10
+
11
+
12
+ def save_url
13
+ if self[:id] == nil && self.class.respond_to?(:create)
14
+ self.relative_save_url
15
+ else
16
+ url
17
+ end
18
+ end
19
+
20
+
21
+ def parentize_url
22
+ if parent_obj.include?(:customer)
23
+ "#{Customer.url}/#{CGI.escape(parent_obj[:customer])}/customer_balance_transactions/#{CGI.escape(id)}"
24
+ else
25
+ url
26
+ end
27
+ end
28
+
29
+
30
+
31
+ def relative_save_url
32
+ if self[:customer]
33
+ "#{Customer.url}/#{CGI.escape(self[:customer])}/customer_balance_transactions"
34
+ end
35
+ end
36
+
37
+
38
+ def self.url
39
+ if @parent_resource.include?(:customer)
40
+ "#{Customer.url}/#{CGI.escape(@parent_resource[:customer])}/customer_balance_transactions"
41
+ end
42
+ end
43
+
44
+ def self.set_parent_resource(filters)
45
+ @parent_resource = filters.select{|k, v| [:customer].include?(k)}
46
+ end
47
+
48
+
49
+ end
50
+ end
@@ -37,6 +37,17 @@ module Octobat
37
37
  response, api_key = Octobat.request(:patch, confirm_url, @api_key, params, opts)
38
38
  refresh_from(response, api_key)
39
39
  end
40
+
41
+ def set_payment_terms(params = {}, opts = {})
42
+ response, api_key = Octobat.request(:patch, set_payment_terms_url, @api_key, params, opts)
43
+ refresh_from(response, api_key)
44
+ end
45
+
46
+ def mark_uncollectible(params = {}, opts = {})
47
+ response, api_key = Octobat.request(:patch, mark_uncollectible_url, @api_key, params, opts)
48
+ refresh_from(response, api_key)
49
+ end
50
+
40
51
 
41
52
  def cancel(params = {}, opts = {})
42
53
  response, api_key = Octobat.request(:patch, cancel_url, @api_key, params, opts)
@@ -71,6 +82,14 @@ module Octobat
71
82
  def confirm_url
72
83
  url + '/confirm'
73
84
  end
85
+
86
+ def mark_uncollectible_url
87
+ url + '/mark_uncollectible'
88
+ end
89
+
90
+ def set_payment_terms_url
91
+ url + '/set_payment_terms'
92
+ end
74
93
 
75
94
  def cancel_url
76
95
  url + '/cancel'
@@ -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
@@ -0,0 +1,13 @@
1
+ module Octobat
2
+ class Subscription < APIResource
3
+ extend Octobat::APIOperations::List
4
+ include Octobat::APIOperations::Create
5
+
6
+ def usage_items(params = {}, opts = {})
7
+ UsageItem.list(params.merge({ subscription: id }), { api_key: @api_key }.merge(opts))
8
+ end
9
+
10
+ end
11
+
12
+
13
+ end
@@ -0,0 +1,51 @@
1
+ module Octobat
2
+ class UsageItem < APIResource
3
+ extend Octobat::APIOperations::List
4
+ include Octobat::APIOperations::Create
5
+ include Octobat::APIOperations::Delete
6
+
7
+
8
+ def url
9
+ !parent_obj.nil? ? parentize_url : super
10
+ end
11
+
12
+
13
+ def save_url
14
+ if self[:id] == nil && self.class.respond_to?(:create)
15
+ self.relative_save_url
16
+ else
17
+ url
18
+ end
19
+ end
20
+
21
+
22
+ def parentize_url
23
+ if parent_obj.include?(:subscription)
24
+ "#{Subscription.url}/#{CGI.escape(parent_obj[:subscription])}/usage_items/#{CGI.escape(id)}"
25
+ else
26
+ url
27
+ end
28
+ end
29
+
30
+
31
+
32
+ def relative_save_url
33
+ if self[:subscription]
34
+ "#{Subscription.url}/#{CGI.escape(self[:subscription])}/usage_items"
35
+ end
36
+ end
37
+
38
+
39
+ def self.url
40
+ if @parent_resource.include?(:subscription)
41
+ "#{Subscription.url}/#{CGI.escape(@parent_resource[:subscription])}/usage_items"
42
+ end
43
+ end
44
+
45
+ def self.set_parent_resource(filters)
46
+ @parent_resource = filters.select{|k, v| [:subscription].include?(k)}
47
+ end
48
+
49
+
50
+ end
51
+ end
data/lib/octobat/util.rb CHANGED
@@ -49,6 +49,7 @@ module Octobat
49
49
  'item' => Item,
50
50
  'purchase_item' => PurchaseItem,
51
51
  'customer' => Customer,
52
+ 'customer_balance_transaction' => CustomerBalanceTransaction,
52
53
  'supplier' => Supplier,
53
54
  'self_billing_invoice' => SelfBillingInvoice,
54
55
  'payout' => Payout,
@@ -69,9 +70,14 @@ module Octobat
69
70
  'exports_setting' => ExportsSetting,
70
71
  'document' => Document,
71
72
  'emails_setting' => EmailsSetting,
73
+ 'subscription' => Subscription,
74
+ 'usage_item' => UsageItem,
72
75
  'file' => FileUpload,
73
76
  'file_link' => FileLink,
74
77
  'beanie.session' => Beanie::Session,
78
+ 'plaza.account' => Plaza::Account,
79
+ 'plaza.capability' => Plaza::Capability,
80
+ 'plaza.country_spec' => Plaza::CountrySpec,
75
81
  'reporting.report_type' => Reporting::ReportType,
76
82
  'reporting.report_run' => Reporting::ReportRun
77
83
  }
@@ -1,3 +1,3 @@
1
1
  module Octobat
2
- VERSION = '2.0.21'
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.21
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-11-12 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
@@ -68,6 +68,7 @@ files:
68
68
  - lib/octobat/credit_note.rb
69
69
  - lib/octobat/credit_note_numbering_sequence.rb
70
70
  - lib/octobat/customer.rb
71
+ - lib/octobat/customer_balance_transaction.rb
71
72
  - lib/octobat/document.rb
72
73
  - lib/octobat/document_email_template.rb
73
74
  - lib/octobat/document_language.rb
@@ -93,6 +94,9 @@ files:
93
94
  - lib/octobat/payment_recipient_reference.rb
94
95
  - lib/octobat/payment_source.rb
95
96
  - lib/octobat/payout.rb
97
+ - lib/octobat/plaza/account.rb
98
+ - lib/octobat/plaza/capability.rb
99
+ - lib/octobat/plaza/country_spec.rb
96
100
  - lib/octobat/product.rb
97
101
  - lib/octobat/proforma_invoice.rb
98
102
  - lib/octobat/purchase_item.rb
@@ -100,12 +104,14 @@ files:
100
104
  - lib/octobat/reporting/report_type.rb
101
105
  - lib/octobat/self_billing_invoice.rb
102
106
  - lib/octobat/singleton_api_resource.rb
107
+ - lib/octobat/subscription.rb
103
108
  - lib/octobat/supplier.rb
104
109
  - lib/octobat/tax_evidence.rb
105
110
  - lib/octobat/tax_evidence_request.rb
106
111
  - lib/octobat/tax_id.rb
107
112
  - lib/octobat/tax_region_setting.rb
108
113
  - lib/octobat/transaction.rb
114
+ - lib/octobat/usage_item.rb
109
115
  - lib/octobat/util.rb
110
116
  - lib/octobat/version.rb
111
117
  - octobat.gemspec