killbill-client 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -12
  3. data/killbill_client.gemspec +1 -1
  4. data/lib/killbill_client/api/net_http_adapter.rb +10 -3
  5. data/lib/killbill_client/models/account.rb +13 -0
  6. data/lib/killbill_client/models/bundle.rb +8 -3
  7. data/lib/killbill_client/models/catalog.rb +26 -5
  8. data/lib/killbill_client/models/gen/account_attributes.rb +3 -0
  9. data/lib/killbill_client/models/gen/bulk_base_subscription_and_add_ons_attributes.rb +34 -0
  10. data/lib/killbill_client/models/gen/invoice_attributes.rb +2 -0
  11. data/lib/killbill_client/models/gen/invoice_item_attributes.rb +2 -0
  12. data/lib/killbill_client/models/gen/invoice_payment_attributes.rb +1 -0
  13. data/lib/killbill_client/models/gen/limit_attributes.rb +36 -0
  14. data/lib/killbill_client/models/gen/overdue_attributes.rb +35 -0
  15. data/lib/killbill_client/models/gen/overdue_condition_attributes.rb +39 -0
  16. data/lib/killbill_client/models/gen/overdue_state_config_attributes.rb +41 -0
  17. data/lib/killbill_client/models/gen/payment_attempt_attributes.rb +46 -0
  18. data/lib/killbill_client/models/gen/payment_attributes.rb +1 -0
  19. data/lib/killbill_client/models/gen/phase_attributes.rb +1 -0
  20. data/lib/killbill_client/models/gen/require_gen.rb +10 -0
  21. data/lib/killbill_client/models/gen/simple_plan_attributes.rb +42 -0
  22. data/lib/killbill_client/models/gen/subscription_attributes.rb +1 -0
  23. data/lib/killbill_client/models/gen/tier_attributes.rb +37 -0
  24. data/lib/killbill_client/models/gen/tiered_block_attributes.rb +37 -0
  25. data/lib/killbill_client/models/gen/usage_attributes.rb +35 -0
  26. data/lib/killbill_client/models/invoice.rb +20 -6
  27. data/lib/killbill_client/models/invoice_item.rb +2 -2
  28. data/lib/killbill_client/models/invoice_payment.rb +3 -1
  29. data/lib/killbill_client/models/models.rb +2 -0
  30. data/lib/killbill_client/models/overdue.rb +22 -8
  31. data/lib/killbill_client/models/overdue_condition.rb +10 -0
  32. data/lib/killbill_client/models/overdue_state_config.rb +10 -0
  33. data/lib/killbill_client/models/payment.rb +5 -2
  34. data/lib/killbill_client/models/payment_method.rb +13 -4
  35. data/lib/killbill_client/models/phase.rb +2 -1
  36. data/lib/killbill_client/models/resource.rb +16 -19
  37. data/lib/killbill_client/models/resources.rb +2 -2
  38. data/lib/killbill_client/models/tenant.rb +19 -5
  39. data/lib/killbill_client/models/transaction.rb +20 -2
  40. data/lib/killbill_client/version.rb +1 -1
  41. data/spec/killbill_client/{encoding_spec.rb → http_adapter_spec.rb} +21 -0
  42. data/spec/killbill_client/remote/model_spec.rb +19 -21
  43. data/spec/spec_helper.rb +1 -1
  44. metadata +53 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c703102c2d5b0ca273db8faa154cc6875b2b6021
4
- data.tar.gz: 660786f1bf17d6bec10c01720ac0550de1f59f5c
3
+ metadata.gz: d524b522d967389b15689ae165caed6c0a01dfaf
4
+ data.tar.gz: 04d0b19fbb503cb3c6cc23eb7634b3171af89bfd
5
5
  SHA512:
6
- metadata.gz: fe35609bef6402e72d22dd442f8c2dc875e69a49cd3ececf6fda7e04a7fc455178d41ab2f239fc8e8364b86f4e8db91f8cd35774702ee4b35b5547d343272ad9
7
- data.tar.gz: 72a29072e1eafcc1c6f1b0fedca4fa248191b1fe5498892411f671c9a5be7e9bf79ce2967752706b1d7b04edf6857c09ef55ecae5e00b4f9eab8f5a82cd6d638
6
+ metadata.gz: c296fb2a05dfbaed883f39d7f567706028e66d67019525caa7fdb55edaea86008786cbe4e35fa2eb359a7bae0bf79a42235b01a96ba6ccc1d66ae1e6834771fc
7
+ data.tar.gz: f2656590d9c4b94ff82ca5c67fd5d3b2d86c2d7437845362ed3ec100a404bea4d629743a48e52db60272cdfb840a01bf1dedb6b305cfbddd6bfca18b92441aea
data/README.md CHANGED
@@ -1,19 +1,16 @@
1
- [![Build Status](https://travis-ci.org/killbill/killbill-client-ruby.png)](https://travis-ci.org/killbill/killbill-client-ruby)
2
- [![Code Climate](https://codeclimate.com/github/killbill/killbill-client-ruby.png)](https://codeclimate.com/github/killbill/killbill-client-ruby)
3
-
4
- ------------------------------------------------
5
- | Ruby client | Kill Bill version |
6
- | -----------------------: | ----------------: |
7
- | 0.x.y | 0.16.z |
8
- | -----------------------: | ----------------: |
9
- | 1.x.y | 0.18.z(and 0.17.x)|
10
-
11
-
12
1
  killbill-client-ruby
13
2
  ====================
14
3
 
15
4
  Kill Bill Ruby client library.
16
5
 
6
+ Kill Bill compatibility
7
+ -----------------------
8
+
9
+ | Client version | Kill Bill version |
10
+ | -------------: | ----------------: |
11
+ | 0.x.y | 0.16.z |
12
+ | 1.x.y | 0.18.z |
13
+
17
14
  Installation
18
15
  ------------
19
16
 
@@ -26,7 +23,7 @@ gem install killbill-client
26
23
  Alternatively, add the dependency in your Gemfile:
27
24
 
28
25
  ```
29
- gem 'killbill-client', '~> 0.24'
26
+ gem 'killbill-client', '~> 1.0'
30
27
  ```
31
28
 
32
29
  Examples
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
39
39
 
40
40
  s.rdoc_options << '--exclude' << '.'
41
41
 
42
- s.add_dependency 'json', '>= 1.2.0'
42
+ s.add_dependency 'json', '>= 1.2.0', '< 2.0.0'
43
43
 
44
44
  s.add_development_dependency 'rake', '>= 10.0.0', '< 11.0.0'
45
45
  s.add_development_dependency 'rspec', '~> 3.4'
@@ -63,6 +63,14 @@ module KillBillClient
63
63
  "?#{pairs.join '&'}"
64
64
  end
65
65
 
66
+ def create_http_client(uri, options = {})
67
+ http = ::Net::HTTP.new uri.host, uri.port
68
+ http.read_timeout = options[:read_timeout].to_f / 1000 if options[:read_timeout].is_a? Numeric
69
+ http.open_timeout = options[:connection_timeout].to_f / 1000 if options[:connection_timeout].is_a? Numeric
70
+ http.use_ssl = uri.scheme == 'https'
71
+ http
72
+ end
73
+
66
74
  def request(method, relative_uri, options = {})
67
75
  head = headers.dup
68
76
  head.update options[:head] if options[:head]
@@ -74,7 +82,7 @@ module KillBillClient
74
82
  # Note: make sure to keep the full path (if any) from URI::HTTP, for non-ROOT deployments
75
83
  # See https://github.com/killbill/killbill/issues/221#issuecomment-151980263
76
84
  base_path = uri.request_uri == '/' ? '' : uri.request_uri
77
- uri += (base_path + URI.escape(relative_uri))
85
+ uri += (base_path + URI::DEFAULT_PARSER.escape(relative_uri))
78
86
  else
79
87
  uri = relative_uri
80
88
  uri = URI.parse(uri) unless uri.is_a?(URI)
@@ -140,8 +148,7 @@ module KillBillClient
140
148
  request['X-Request-Id'] = options[:request_id]
141
149
  end
142
150
 
143
- http = ::Net::HTTP.new uri.host, uri.port
144
- http.use_ssl = uri.scheme == 'https'
151
+ http = create_http_client uri, options
145
152
  net_http.each_pair { |key, value| http.send "#{key}=", value }
146
153
 
147
154
  if KillBillClient.logger
@@ -79,6 +79,19 @@ module KillBillClient
79
79
  updated_account.refresh(options)
80
80
  end
81
81
 
82
+
83
+ def transfer_child_credit(user = nil, reason = nil, comment = nil, options = {})
84
+ self.class.post "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/transferCredit",
85
+ {},
86
+ {},
87
+ {
88
+ :user => user,
89
+ :reason => reason,
90
+ :comment => comment,
91
+ }.merge(options)
92
+ end
93
+
94
+
82
95
  def bundles(options = {})
83
96
  self.class.get "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/bundles",
84
97
  {},
@@ -39,10 +39,15 @@ module KillBillClient
39
39
  end
40
40
 
41
41
  # Return the active one
42
- def find_by_external_key(external_key, options = {})
43
- get "#{KILLBILL_API_BUNDLES_PREFIX}?externalKey=#{external_key}",
44
- {},
42
+ def find_by_external_key(external_key, included_deleted, options = {})
43
+ params = {}
44
+ params[:externalKey] = external_key
45
+ params[:includedDeleted] = included_deleted if included_deleted
46
+
47
+ result = get "#{KILLBILL_API_BUNDLES_PREFIX}",
48
+ params,
45
49
  options
50
+ return included_deleted ? result : result[0]
46
51
  end
47
52
 
48
53
  # Return active and inactive ones
@@ -29,15 +29,21 @@ module KillBillClient
29
29
  PlanDetail
30
30
  end
31
31
 
32
- def get_tenant_catalog(options = {})
32
+ def get_tenant_catalog(format, requested_date=nil, options = {})
33
33
 
34
34
  require_multi_tenant_options!(options, "Retrieving a catalog is only supported in multi-tenant mode")
35
35
 
36
+ params = {}
37
+ params[:requestedDate] = requested_date if requested_date
38
+
36
39
  get KILLBILL_API_CATALOG_PREFIX,
37
- {},
40
+ params,
38
41
  {
39
- :head => {'Accept' => 'application/xml'},
40
- }.merge(options)
42
+ :head => {'Accept' => "application/#{format}"},
43
+ :content_type => "application/#{format}",
44
+
45
+ }.merge(options)
46
+
41
47
  end
42
48
 
43
49
  def upload_tenant_catalog(catalog_xml, user = nil, reason = nil, comment = nil, options = {})
@@ -55,9 +61,24 @@ module KillBillClient
55
61
  :reason => reason,
56
62
  :comment => comment,
57
63
  }.merge(options)
58
- get_tenant_catalog(options)
64
+ get_tenant_catalog('xml', nil, options)
59
65
  end
60
66
 
67
+
68
+ def add_tenant_catalog_simple_plan(simple_plan, user = nil, reason = nil, comment = nil, options = {})
69
+
70
+ require_multi_tenant_options!(options, "Uploading a catalog is only supported in multi-tenant mode")
71
+
72
+ post "#{KILLBILL_API_CATALOG_PREFIX}/simplePlan",
73
+ simple_plan.to_json,
74
+ {
75
+ },
76
+ {
77
+ :user => user,
78
+ :reason => reason,
79
+ :comment => comment,
80
+ }.merge(options)
81
+ end
61
82
  end
62
83
  end
63
84
  end
@@ -35,6 +35,8 @@ module KillBillClient
35
35
  attribute :email
36
36
  attribute :bill_cycle_day_local
37
37
  attribute :currency
38
+ attribute :parent_account_id
39
+ attribute :is_payment_delegated_to_parent
38
40
  attribute :payment_method_id
39
41
  attribute :time_zone
40
42
  attribute :address1
@@ -46,6 +48,7 @@ module KillBillClient
46
48
  attribute :country
47
49
  attribute :locale
48
50
  attribute :phone
51
+ attribute :notes
49
52
  attribute :is_migrated
50
53
  attribute :is_notified_for_invoices
51
54
  attribute :account_balance
@@ -0,0 +1,34 @@
1
+ #############################################################################################
2
+ # #
3
+ # Copyright 2010-2013 Ning, Inc. #
4
+ # Copyright 2014 Groupon, Inc. #
5
+ # Copyright 2014 The Billing Project, LLC #
6
+ # #
7
+ # The Billing Project licenses this file to you under the Apache License, version 2.0 #
8
+ # (the "License"); you may not use this file except in compliance with the #
9
+ # License. You may obtain a copy of the License at: #
10
+ # #
11
+ # http://www.apache.org/licenses/LICENSE-2.0 #
12
+ # #
13
+ # Unless required by applicable law or agreed to in writing, software #
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
16
+ # License for the specific language governing permissions and limitations #
17
+ # under the License. #
18
+ # #
19
+ #############################################################################################
20
+
21
+
22
+ #
23
+ # DO NOT EDIT!!!
24
+ # File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
25
+ #
26
+
27
+
28
+ module KillBillClient
29
+ module Model
30
+ class BulkBaseSubscriptionAndAddOnsAttributes < Resource
31
+ attribute :base_entitlement_and_add_ons
32
+ end
33
+ end
34
+ end
@@ -30,6 +30,7 @@ module KillBillClient
30
30
  class InvoiceAttributes < Resource
31
31
  attribute :amount
32
32
  attribute :currency
33
+ attribute :status
33
34
  attribute :credit_adj
34
35
  attribute :refund_adj
35
36
  attribute :invoice_id
@@ -41,6 +42,7 @@ module KillBillClient
41
42
  attribute :external_bundle_keys
42
43
  attribute :credits
43
44
  attribute :items
45
+ attribute :is_parent_invoice
44
46
  attribute :audit_logs
45
47
  end
46
48
  end
@@ -32,6 +32,7 @@ module KillBillClient
32
32
  attribute :invoice_id
33
33
  attribute :linked_invoice_item_id
34
34
  attribute :account_id
35
+ attribute :child_account_id
35
36
  attribute :bundle_id
36
37
  attribute :subscription_id
37
38
  attribute :plan_name
@@ -43,6 +44,7 @@ module KillBillClient
43
44
  attribute :end_date
44
45
  attribute :amount
45
46
  attribute :currency
47
+ attribute :child_items
46
48
  attribute :audit_logs
47
49
  end
48
50
  end
@@ -41,6 +41,7 @@ module KillBillClient
41
41
  attribute :currency
42
42
  attribute :payment_method_id
43
43
  attribute :transactions
44
+ attribute :payment_attempts
44
45
  attribute :audit_logs
45
46
  end
46
47
  end
@@ -0,0 +1,36 @@
1
+ #############################################################################################
2
+ # #
3
+ # Copyright 2010-2013 Ning, Inc. #
4
+ # Copyright 2014 Groupon, Inc. #
5
+ # Copyright 2014 The Billing Project, LLC #
6
+ # #
7
+ # The Billing Project licenses this file to you under the Apache License, version 2.0 #
8
+ # (the "License"); you may not use this file except in compliance with the #
9
+ # License. You may obtain a copy of the License at: #
10
+ # #
11
+ # http://www.apache.org/licenses/LICENSE-2.0 #
12
+ # #
13
+ # Unless required by applicable law or agreed to in writing, software #
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
16
+ # License for the specific language governing permissions and limitations #
17
+ # under the License. #
18
+ # #
19
+ #############################################################################################
20
+
21
+
22
+ #
23
+ # DO NOT EDIT!!!
24
+ # File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
25
+ #
26
+
27
+
28
+ module KillBillClient
29
+ module Model
30
+ class LimitAttributes < Resource
31
+ attribute :unit
32
+ attribute :max
33
+ attribute :min
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,35 @@
1
+ #############################################################################################
2
+ # #
3
+ # Copyright 2010-2013 Ning, Inc. #
4
+ # Copyright 2014 Groupon, Inc. #
5
+ # Copyright 2014 The Billing Project, LLC #
6
+ # #
7
+ # The Billing Project licenses this file to you under the Apache License, version 2.0 #
8
+ # (the "License"); you may not use this file except in compliance with the #
9
+ # License. You may obtain a copy of the License at: #
10
+ # #
11
+ # http://www.apache.org/licenses/LICENSE-2.0 #
12
+ # #
13
+ # Unless required by applicable law or agreed to in writing, software #
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
16
+ # License for the specific language governing permissions and limitations #
17
+ # under the License. #
18
+ # #
19
+ #############################################################################################
20
+
21
+
22
+ #
23
+ # DO NOT EDIT!!!
24
+ # File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
25
+ #
26
+
27
+
28
+ module KillBillClient
29
+ module Model
30
+ class OverdueAttributes < Resource
31
+ attribute :initial_reevaluation_interval
32
+ attribute :overdue_states
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,39 @@
1
+ #############################################################################################
2
+ # #
3
+ # Copyright 2010-2013 Ning, Inc. #
4
+ # Copyright 2014 Groupon, Inc. #
5
+ # Copyright 2014 The Billing Project, LLC #
6
+ # #
7
+ # The Billing Project licenses this file to you under the Apache License, version 2.0 #
8
+ # (the "License"); you may not use this file except in compliance with the #
9
+ # License. You may obtain a copy of the License at: #
10
+ # #
11
+ # http://www.apache.org/licenses/LICENSE-2.0 #
12
+ # #
13
+ # Unless required by applicable law or agreed to in writing, software #
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
16
+ # License for the specific language governing permissions and limitations #
17
+ # under the License. #
18
+ # #
19
+ #############################################################################################
20
+
21
+
22
+ #
23
+ # DO NOT EDIT!!!
24
+ # File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
25
+ #
26
+
27
+
28
+ module KillBillClient
29
+ module Model
30
+ class OverdueConditionAttributes < Resource
31
+ attribute :time_since_earliest_unpaid_invoice_equals_or_exceeds
32
+ attribute :control_tag_inclusion
33
+ attribute :control_tag_exclusion
34
+ attribute :number_of_unpaid_invoices_equals_or_exceeds
35
+ attribute :response_for_last_failed_payment
36
+ attribute :total_unpaid_invoice_balance_equals_or_exceeds
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,41 @@
1
+ #############################################################################################
2
+ # #
3
+ # Copyright 2010-2013 Ning, Inc. #
4
+ # Copyright 2014 Groupon, Inc. #
5
+ # Copyright 2014 The Billing Project, LLC #
6
+ # #
7
+ # The Billing Project licenses this file to you under the Apache License, version 2.0 #
8
+ # (the "License"); you may not use this file except in compliance with the #
9
+ # License. You may obtain a copy of the License at: #
10
+ # #
11
+ # http://www.apache.org/licenses/LICENSE-2.0 #
12
+ # #
13
+ # Unless required by applicable law or agreed to in writing, software #
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
16
+ # License for the specific language governing permissions and limitations #
17
+ # under the License. #
18
+ # #
19
+ #############################################################################################
20
+
21
+
22
+ #
23
+ # DO NOT EDIT!!!
24
+ # File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
25
+ #
26
+
27
+
28
+ module KillBillClient
29
+ module Model
30
+ class OverdueStateConfigAttributes < Resource
31
+ attribute :name
32
+ attribute :is_clear_state
33
+ attribute :condition
34
+ attribute :external_message
35
+ attribute :block_changes
36
+ attribute :disable_entitlement
37
+ attribute :subscription_cancellation_policy
38
+ attribute :auto_reevaluation_interval_days
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,46 @@
1
+ #############################################################################################
2
+ # #
3
+ # Copyright 2010-2013 Ning, Inc. #
4
+ # Copyright 2014 Groupon, Inc. #
5
+ # Copyright 2014 The Billing Project, LLC #
6
+ # #
7
+ # The Billing Project licenses this file to you under the Apache License, version 2.0 #
8
+ # (the "License"); you may not use this file except in compliance with the #
9
+ # License. You may obtain a copy of the License at: #
10
+ # #
11
+ # http://www.apache.org/licenses/LICENSE-2.0 #
12
+ # #
13
+ # Unless required by applicable law or agreed to in writing, software #
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
16
+ # License for the specific language governing permissions and limitations #
17
+ # under the License. #
18
+ # #
19
+ #############################################################################################
20
+
21
+
22
+ #
23
+ # DO NOT EDIT!!!
24
+ # File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
25
+ #
26
+
27
+
28
+ module KillBillClient
29
+ module Model
30
+ class PaymentAttemptAttributes < Resource
31
+ attribute :account_id
32
+ attribute :payment_method_id
33
+ attribute :payment_external_key
34
+ attribute :transaction_id
35
+ attribute :transaction_external_key
36
+ attribute :transaction_type
37
+ attribute :effective_date
38
+ attribute :state_name
39
+ attribute :amount
40
+ attribute :currency
41
+ attribute :plugin_name
42
+ attribute :plugin_properties
43
+ attribute :audit_logs
44
+ end
45
+ end
46
+ end