killbill-client 3.0.0 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +15 -109
  3. data/.github/CONTRIBUTING.md +20 -0
  4. data/.github/FUNDING.yml +3 -0
  5. data/.github/workflows/ci.yml +145 -0
  6. data/.github/workflows/release.yml +46 -0
  7. data/README.md +32 -1
  8. data/bin/retry +21 -0
  9. data/docker/docker-compose.ci.mysql.yml +21 -0
  10. data/docker/docker-compose.ci.postgresql.yml +21 -0
  11. data/killbill_client.gemspec +2 -1
  12. data/lib/killbill_client.rb +2 -0
  13. data/lib/killbill_client/api/api.rb +1 -1
  14. data/lib/killbill_client/api/net_http_adapter.rb +13 -2
  15. data/lib/killbill_client/models/account.rb +3 -5
  16. data/lib/killbill_client/models/credit.rb +5 -5
  17. data/lib/killbill_client/models/custom_field.rb +17 -0
  18. data/lib/killbill_client/models/gen/invoice_attributes.rb +1 -0
  19. data/lib/killbill_client/models/gen/invoice_item_attributes.rb +1 -0
  20. data/lib/killbill_client/models/gen/overdue_state_attributes.rb +0 -1
  21. data/lib/killbill_client/models/gen/require_gen.rb +52 -53
  22. data/lib/killbill_client/models/gen/subscription_attributes.rb +1 -0
  23. data/lib/killbill_client/models/helpers/custom_field_helper.rb +1 -1
  24. data/lib/killbill_client/models/invoice.rb +4 -7
  25. data/lib/killbill_client/models/subscription.rb +10 -0
  26. data/lib/killbill_client/version.rb +1 -16
  27. data/spec/killbill_client/http_adapter_spec.rb +32 -0
  28. data/spec/killbill_client/remote/model_spec.rb +15 -11
  29. metadata +25 -8
  30. data/lib/killbill_client/models/gen/block_price_override_attributes.rb +0 -37
  31. data/lib/killbill_client/models/gen/credit_attributes.rb +0 -43
  32. data/lib/killbill_client/models/gen/phase_price_override_attributes.rb +0 -39
  33. data/lib/killbill_client/models/gen/tier_price_override_attributes.rb +0 -34
  34. data/lib/killbill_client/models/gen/usage_price_override_attributes.rb +0 -38
data/bin/retry ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ x() {
6
+ echo "+ $*" >&2
7
+ "$@"
8
+ }
9
+
10
+ retry_delay_seconds=10
11
+
12
+ i="0"
13
+ while [ $i -lt 4 ]
14
+ do
15
+ x "$@" && exit 0
16
+ sleep "${retry_delay_seconds}"
17
+ i=$[$i+1]
18
+ done
19
+
20
+ echo "$0: retrying [$*] timed out" >&2
21
+ exit 1
@@ -0,0 +1,21 @@
1
+ version: '3.8'
2
+
3
+ services:
4
+ killbill:
5
+ network_mode: host
6
+ image: killbill/killbill:0.22.20
7
+ environment:
8
+ - KILLBILL_CATALOG_URI=SpyCarAdvanced.xml
9
+ - KILLBILL_DAO_URL=jdbc:mysql://127.0.0.1:3306/killbill
10
+ - KILLBILL_DAO_USER=root
11
+ - KILLBILL_DAO_PASSWORD=root
12
+ - KILLBILL_SERVER_TEST_MODE=true
13
+ - KILLBILL_INVOICE_SANITY_SAFETY_BOUND_ENABLED=false
14
+ - KILLBILL_INVOICE_MAX_DAILY_NUMBER_OF_ITEMS_SAFETY_BOUND=-1
15
+ depends_on:
16
+ - db
17
+ db:
18
+ network_mode: host
19
+ image: killbill/mariadb:0.22
20
+ environment:
21
+ - MYSQL_ROOT_PASSWORD=root
@@ -0,0 +1,21 @@
1
+ version: '3.8'
2
+
3
+ services:
4
+ killbill:
5
+ network_mode: host
6
+ image: killbill/killbill:0.22.20
7
+ environment:
8
+ - KILLBILL_CATALOG_URI=SpyCarAdvanced.xml
9
+ - KILLBILL_DAO_URL=jdbc:postgresql://127.0.0.1:5432/killbill
10
+ - KILLBILL_DAO_USER=postgres
11
+ - KILLBILL_DAO_PASSWORD=postgres
12
+ - KILLBILL_SERVER_TEST_MODE=true
13
+ - KILLBILL_INVOICE_SANITY_SAFETY_BOUND_ENABLED=false
14
+ - KILLBILL_INVOICE_MAX_DAILY_NUMBER_OF_ITEMS_SAFETY_BOUND=-1
15
+ depends_on:
16
+ - db
17
+ db:
18
+ network_mode: host
19
+ image: killbill/postgresql:0.22
20
+ environment:
21
+ - POSTGRES_PASSWORD=postgres
@@ -19,7 +19,7 @@ require 'killbill_client/version'
19
19
 
20
20
  Gem::Specification.new do |s|
21
21
  s.name = 'killbill-client'
22
- s.version = KillBillClient::Version.to_s
22
+ s.version = KillBillClient::VERSION
23
23
  s.summary = 'Kill Bill client library.'
24
24
  s.description = 'An API client library for Kill Bill.'
25
25
 
@@ -43,6 +43,7 @@ Gem::Specification.new do |s|
43
43
  s.add_dependency 'json', '>= 1.2.0', '< 2.0.0'
44
44
  end
45
45
 
46
+ s.add_development_dependency 'gem-release', '~> 2.2'
46
47
  s.add_development_dependency 'rake', '>= 10.0.0', '< 11.0.0'
47
48
  s.add_development_dependency 'rspec', '~> 3.4'
48
49
  end
@@ -41,6 +41,8 @@ module KillBillClient
41
41
 
42
42
  attr_writer :url
43
43
 
44
+ attr_accessor :read_timeout
45
+ attr_accessor :connection_timeout
44
46
  attr_accessor :disable_ssl_verification
45
47
  attr_accessor :return_full_stacktraces
46
48
 
@@ -70,7 +70,7 @@ module KillBillClient
70
70
 
71
71
  # @return [String]
72
72
  def user_agent
73
- "killbill/#{Version}; #{RUBY_DESCRIPTION}"
73
+ "killbill/#{VERSION}; #{RUBY_DESCRIPTION}"
74
74
  end
75
75
 
76
76
  private
@@ -86,8 +86,16 @@ module KillBillClient
86
86
 
87
87
  def create_http_client(uri, options = {})
88
88
  http = ::Net::HTTP.new uri.host, uri.port
89
- http.read_timeout = options[:read_timeout].to_f / 1000 if options[:read_timeout].is_a? Numeric
90
- http.open_timeout = options[:connection_timeout].to_f / 1000 if options[:connection_timeout].is_a? Numeric
89
+ if options[:read_timeout].is_a? Numeric
90
+ http.read_timeout = options[:read_timeout].to_f / 1000
91
+ elsif KillBillClient.read_timeout.is_a? Numeric
92
+ http.read_timeout = KillBillClient.read_timeout.to_f / 1000
93
+ end
94
+ if options[:connection_timeout].is_a? Numeric
95
+ http.open_timeout = options[:connection_timeout].to_f / 1000
96
+ elsif KillBillClient.connection_timeout.is_a? Numeric
97
+ http.open_timeout = KillBillClient.connection_timeout.to_f / 1000
98
+ end
91
99
  http.use_ssl = uri.scheme == 'https'
92
100
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE if (options[:disable_ssl_verification] || KillBillClient.disable_ssl_verification)
93
101
  http
@@ -110,8 +118,11 @@ module KillBillClient
110
118
  # Configure RBAC, if enabled
111
119
  username = options[:username] || KillBillClient.username
112
120
  password = options[:password] || KillBillClient.password
121
+ bearer = options[:bearer]
113
122
  if username and password
114
123
  request.basic_auth(*[username, password].flatten[0, 2])
124
+ elsif bearer
125
+ request['authorization'] = 'Bearer ' + bearer
115
126
  end
116
127
  session_id = options[:session_id]
117
128
  if session_id
@@ -143,20 +143,18 @@ module KillBillClient
143
143
  Bundle
144
144
  end
145
145
 
146
- def invoices(with_items=false, options = {})
146
+ def invoices(options = {})
147
147
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/invoices",
148
148
  {
149
- :withItems => with_items
150
149
  },
151
150
  options,
152
151
  Invoice
153
152
  end
154
153
 
155
- def migration_invoices(with_items=false, options = {})
154
+ def migration_invoices(options = {})
156
155
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/invoices",
157
156
  {
158
- :withMigrationInvoices => true,
159
- :withItems => with_items
157
+ :withMigrationInvoices => true
160
158
  },
161
159
  options,
162
160
  Invoice
@@ -1,6 +1,6 @@
1
1
  module KillBillClient
2
2
  module Model
3
- class Credit < CreditAttributes
3
+ class Credit < InvoiceItemAttributes
4
4
  KILLBILL_API_CREDITS_PREFIX = "#{KILLBILL_API_PREFIX}/credits"
5
5
  has_many :audit_logs, KillBillClient::Model::AuditLog
6
6
 
@@ -9,13 +9,13 @@ module KillBillClient
9
9
  get "#{KILLBILL_API_CREDITS_PREFIX}/#{credit_id}",
10
10
  {},
11
11
  options,
12
- CreditAttributes
12
+ InvoiceItemAttributes
13
13
  end
14
14
  end
15
15
 
16
16
  def create(auto_commit = false, user = nil, reason = nil, comment = nil, options = {})
17
- created_credit = self.class.post KILLBILL_API_CREDITS_PREFIX,
18
- to_json,
17
+ created_credits = self.class.post KILLBILL_API_CREDITS_PREFIX,
18
+ [to_hash].to_json,
19
19
  {
20
20
  :autoCommit => auto_commit
21
21
  },
@@ -24,7 +24,7 @@ module KillBillClient
24
24
  :reason => reason,
25
25
  :comment => comment,
26
26
  }.merge(options)
27
- created_credit.refresh(options)
27
+ created_credits
28
28
  end
29
29
 
30
30
  end
@@ -28,6 +28,23 @@ module KillBillClient
28
28
  },
29
29
  options
30
30
  end
31
+
32
+ def find_in_batches_by_search_type_name(object_type, field_name, field_value, offset = 0, limit = 100, options = {})
33
+
34
+ query_fields = {
35
+ :objectType => object_type,
36
+ :fieldName => field_name,
37
+ :fieldValue => field_value,
38
+ :offset => offset,
39
+ :limit => limit
40
+ }
41
+ query_fields[:fieldValue] = field_value if field_value
42
+
43
+ get "#{KILLBILL_API_CUSTOM_FIELDS_PREFIX}/search",
44
+ query_fields,
45
+ options
46
+ end
47
+
31
48
  end
32
49
  end
33
50
  end
@@ -42,6 +42,7 @@ module KillBillClient
42
42
  attribute :bundle_keys
43
43
  attribute :credits
44
44
  attribute :items
45
+ attribute :tracking_ids
45
46
  attribute :is_parent_invoice
46
47
  attribute :parent_invoice_id
47
48
  attribute :parent_account_id
@@ -52,6 +52,7 @@ module KillBillClient
52
52
  attribute :currency
53
53
  attribute :quantity
54
54
  attribute :item_details
55
+ attribute :catalog_effective_date
55
56
  attribute :child_items
56
57
  attribute :audit_logs
57
58
  end
@@ -30,7 +30,6 @@ module KillBillClient
30
30
  class OverdueStateAttributes < Resource
31
31
  attribute :name
32
32
  attribute :external_message
33
- attribute :days_between_payment_retries
34
33
  attribute :is_disable_entitlement_and_changes_blocked
35
34
  attribute :is_block_changes
36
35
  attribute :is_clear_state
@@ -25,39 +25,26 @@
25
25
  #
26
26
 
27
27
 
28
- require 'killbill_client/models/gen/tenant_attributes'
29
- require 'killbill_client/models/gen/subject_attributes'
30
- require 'killbill_client/models/gen/account_email_attributes'
31
- require 'killbill_client/models/gen/tag_attributes'
32
- require 'killbill_client/models/gen/invoice_attributes'
33
- require 'killbill_client/models/gen/plugin_property_attributes'
34
- require 'killbill_client/models/gen/account_timeline_attributes'
35
- require 'killbill_client/models/gen/overdue_state_attributes'
36
- require 'killbill_client/models/gen/user_roles_attributes'
37
- require 'killbill_client/models/gen/payment_method_plugin_detail_attributes'
38
- require 'killbill_client/models/gen/payment_method_attributes'
39
- require 'killbill_client/models/gen/plugin_service_info_attributes'
40
- require 'killbill_client/models/gen/plugin_info_attributes'
41
- require 'killbill_client/models/gen/tier_price_attributes'
42
- require 'killbill_client/models/gen/tag_definition_attributes'
43
- require 'killbill_client/models/gen/block_price_attributes'
44
- require 'killbill_client/models/gen/account_attributes'
45
- require 'killbill_client/models/gen/hosted_payment_page_form_descriptor_attributes'
46
- require 'killbill_client/models/gen/bulk_subscriptions_bundle_attributes'
47
- require 'killbill_client/models/gen/blocking_state_attributes'
48
28
  require 'killbill_client/models/gen/invoice_item_attributes'
29
+ require 'killbill_client/models/gen/combo_hosted_payment_page_attributes'
30
+ require 'killbill_client/models/gen/simple_plan_attributes'
31
+ require 'killbill_client/models/gen/bundle_timeline_attributes'
32
+ require 'killbill_client/models/gen/payment_transaction_attributes'
33
+ require 'killbill_client/models/gen/unit_usage_record_attributes'
34
+ require 'killbill_client/models/gen/usage_record_attributes'
35
+ require 'killbill_client/models/gen/subscription_usage_record_attributes'
36
+ require 'killbill_client/models/gen/rolled_up_unit_attributes'
37
+ require 'killbill_client/models/gen/rolled_up_usage_attributes'
49
38
  require 'killbill_client/models/gen/role_definition_attributes'
50
- require 'killbill_client/models/gen/node_command_property_attributes'
39
+ require 'killbill_client/models/gen/usage_price_attributes'
40
+ require 'killbill_client/models/gen/combo_payment_transaction_attributes'
41
+ require 'killbill_client/models/gen/hosted_payment_page_fields_attributes'
42
+ require 'killbill_client/models/gen/plan_detail_attributes'
51
43
  require 'killbill_client/models/gen/invoice_payment_transaction_attributes'
44
+ require 'killbill_client/models/gen/overdue_attributes'
45
+ require 'killbill_client/models/gen/tier_price_attributes'
46
+ require 'killbill_client/models/gen/tag_definition_attributes'
52
47
  require 'killbill_client/models/gen/hosted_payment_page_billing_address_attributes'
53
- require 'killbill_client/models/gen/plan_detail_attributes'
54
- require 'killbill_client/models/gen/custom_field_attributes'
55
- require 'killbill_client/models/gen/rolled_up_unit_attributes'
56
- require 'killbill_client/models/gen/rolled_up_usage_attributes'
57
- require 'killbill_client/models/gen/gateway_notification_attributes'
58
- require 'killbill_client/models/gen/event_subscription_attributes'
59
- require 'killbill_client/models/gen/subscription_attributes'
60
- require 'killbill_client/models/gen/notification_attributes'
61
48
  require 'killbill_client/models/gen/unit_attributes'
62
49
  require 'killbill_client/models/gen/product_attributes'
63
50
  require 'killbill_client/models/gen/plan_attributes'
@@ -70,34 +57,46 @@ require 'killbill_client/models/gen/price_attributes'
70
57
  require 'killbill_client/models/gen/price_list_attributes'
71
58
  require 'killbill_client/models/gen/duration_attributes'
72
59
  require 'killbill_client/models/gen/catalog_attributes'
73
- require 'killbill_client/models/gen/combo_payment_transaction_attributes'
74
- require 'killbill_client/models/gen/usage_price_attributes'
60
+ require 'killbill_client/models/gen/custom_field_attributes'
61
+ require 'killbill_client/models/gen/overdue_state_attributes'
62
+ require 'killbill_client/models/gen/overdue_condition_attributes'
75
63
  require 'killbill_client/models/gen/bundle_attributes'
76
- require 'killbill_client/models/gen/payment_transaction_attributes'
64
+ require 'killbill_client/models/gen/invoice_attributes'
77
65
  require 'killbill_client/models/gen/payment_attributes'
78
- require 'killbill_client/models/gen/unit_usage_record_attributes'
79
- require 'killbill_client/models/gen/usage_record_attributes'
80
- require 'killbill_client/models/gen/subscription_usage_record_attributes'
81
- require 'killbill_client/models/gen/overdue_attributes'
82
- require 'killbill_client/models/gen/stack_trace_element_attributes'
83
- require 'killbill_client/models/gen/billing_exception_attributes'
84
- require 'killbill_client/models/gen/audit_log_attributes'
66
+ require 'killbill_client/models/gen/node_command_attributes'
67
+ require 'killbill_client/models/gen/payment_method_plugin_detail_attributes'
68
+ require 'killbill_client/models/gen/payment_method_attributes'
69
+ require 'killbill_client/models/gen/node_command_property_attributes'
70
+ require 'killbill_client/models/gen/tenant_key_value_attributes'
85
71
  require 'killbill_client/models/gen/phase_price_attributes'
72
+ require 'killbill_client/models/gen/overdue_state_config_attributes'
73
+ require 'killbill_client/models/gen/invoice_payment_attributes'
74
+ require 'killbill_client/models/gen/blocking_state_attributes'
75
+ require 'killbill_client/models/gen/audit_log_attributes'
76
+ require 'killbill_client/models/gen/payment_attempt_attributes'
77
+ require 'killbill_client/models/gen/node_info_attributes'
78
+ require 'killbill_client/models/gen/notification_attributes'
79
+ require 'killbill_client/models/gen/event_subscription_attributes'
80
+ require 'killbill_client/models/gen/subscription_attributes'
81
+ require 'killbill_client/models/gen/account_timeline_attributes'
82
+ require 'killbill_client/models/gen/plugin_service_info_attributes'
83
+ require 'killbill_client/models/gen/plugin_info_attributes'
84
+ require 'killbill_client/models/gen/tenant_attributes'
85
+ require 'killbill_client/models/gen/plugin_property_attributes'
86
+ require 'killbill_client/models/gen/user_roles_attributes'
86
87
  require 'killbill_client/models/gen/profiling_data_attributes_item'
87
88
  require 'killbill_client/models/gen/profiling_data_attributes'
88
- require 'killbill_client/models/gen/node_command_attributes'
89
- require 'killbill_client/models/gen/session_attributes'
90
- require 'killbill_client/models/gen/hosted_payment_page_customer_attributes'
91
- require 'killbill_client/models/gen/tenant_key_value_attributes'
92
89
  require 'killbill_client/models/gen/admin_payment_attributes'
93
- require 'killbill_client/models/gen/bundle_timeline_attributes'
90
+ require 'killbill_client/models/gen/account_email_attributes'
91
+ require 'killbill_client/models/gen/hosted_payment_page_form_descriptor_attributes'
92
+ require 'killbill_client/models/gen/bulk_subscriptions_bundle_attributes'
93
+ require 'killbill_client/models/gen/subject_attributes'
94
+ require 'killbill_client/models/gen/stack_trace_element_attributes'
95
+ require 'killbill_client/models/gen/billing_exception_attributes'
96
+ require 'killbill_client/models/gen/hosted_payment_page_customer_attributes'
97
+ require 'killbill_client/models/gen/gateway_notification_attributes'
98
+ require 'killbill_client/models/gen/account_attributes'
94
99
  require 'killbill_client/models/gen/invoice_dry_run_attributes'
95
- require 'killbill_client/models/gen/payment_attempt_attributes'
96
- require 'killbill_client/models/gen/hosted_payment_page_fields_attributes'
97
- require 'killbill_client/models/gen/invoice_payment_attributes'
98
- require 'killbill_client/models/gen/overdue_state_config_attributes'
99
- require 'killbill_client/models/gen/simple_plan_attributes'
100
- require 'killbill_client/models/gen/combo_hosted_payment_page_attributes'
101
- require 'killbill_client/models/gen/credit_attributes'
102
- require 'killbill_client/models/gen/overdue_condition_attributes'
103
- require 'killbill_client/models/gen/node_info_attributes'
100
+ require 'killbill_client/models/gen/session_attributes'
101
+ require 'killbill_client/models/gen/block_price_attributes'
102
+ require 'killbill_client/models/gen/tag_attributes'
@@ -30,6 +30,7 @@ module KillBillClient
30
30
  class SubscriptionAttributes < Resource
31
31
  attribute :account_id
32
32
  attribute :bundle_id
33
+ attribute :bundle_external_key
33
34
  attribute :subscription_id
34
35
  attribute :external_key
35
36
  attribute :start_date
@@ -71,7 +71,7 @@ module KillBillClient
71
71
  self.class.delete "#{url_prefix}/#{send(id_alias)}/customFields",
72
72
  {},
73
73
  {
74
- :customFieldList => custom_fields_param
74
+ :customField => custom_fields_param
75
75
  },
76
76
  {
77
77
  :user => user,
@@ -11,7 +11,7 @@ module KillBillClient
11
11
 
12
12
  has_many :audit_logs, KillBillClient::Model::AuditLog
13
13
  has_many :items, KillBillClient::Model::InvoiceItem
14
- has_many :credits, KillBillClient::Model::Credit
14
+ has_many :credits, KillBillClient::Model::InvoiceItem
15
15
 
16
16
  has_custom_fields KILLBILL_API_INVOICES_PREFIX, :invoice_id
17
17
  has_tags KILLBILL_API_INVOICES_PREFIX, :invoice_id
@@ -19,29 +19,26 @@ module KillBillClient
19
19
 
20
20
 
21
21
  class << self
22
- def find_by_id(invoice_id, with_items = true, audit = "NONE", options = {})
22
+ def find_by_id(invoice_id, audit = "NONE", options = {})
23
23
  get "#{KILLBILL_API_INVOICES_PREFIX}/#{invoice_id}",
24
24
  {
25
- :withItems => with_items,
26
25
  :audit => audit
27
26
  },
28
27
  options
29
28
  end
30
29
 
31
- def find_by_number(number, with_items = true, audit = "NONE", options = {})
30
+ def find_by_number(number, audit = "NONE", options = {})
32
31
  get "#{KILLBILL_API_INVOICES_PREFIX}/byNumber/#{number}",
33
32
  {
34
- :withItems => with_items,
35
33
  :audit => audit
36
34
  },
37
35
  options
38
36
  end
39
37
 
40
- def find_by_invoice_item_id(invoice_item_id, with_items = true, with_children_items = false, audit = "NONE", options = {})
38
+ def find_by_invoice_item_id(invoice_item_id, with_children_items = false, audit = "NONE", options = {})
41
39
  get "#{KILLBILL_API_INVOICES_PREFIX}/byItemId/#{invoice_item_id}",
42
40
  {
43
41
  :withChildrenItems => with_children_items,
44
- :withItems => with_items,
45
42
  :audit => audit
46
43
  },
47
44
  options
@@ -23,6 +23,16 @@ module KillBillClient
23
23
  options
24
24
  end
25
25
 
26
+ def find_by_external_key(external_key, options = {})
27
+ params = {}
28
+ params[:externalKey] = external_key
29
+
30
+ get "#{KILLBILL_API_ENTITLEMENT_PREFIX}",
31
+ params,
32
+ options
33
+ end
34
+
35
+
26
36
  def event_audit_logs_with_history(event_id, options = {})
27
37
  get "#{KILLBILL_API_ENTITLEMENT_PREFIX}/events/#{event_id}/auditLogsWithHistory",
28
38
  {},