killbill-client 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/lib/killbill_client/api/api.rb +2 -2
- data/lib/killbill_client/api/errors.rb +1 -1
- data/lib/killbill_client/api/net_http_adapter.rb +21 -1
- data/lib/killbill_client/models/account.rb +60 -112
- data/lib/killbill_client/models/account_timeline.rb +1 -1
- data/lib/killbill_client/models/bundle.rb +35 -34
- data/lib/killbill_client/models/catalog.rb +34 -0
- data/lib/killbill_client/models/custom_field.rb +3 -11
- data/lib/killbill_client/models/gen/account_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/account_email_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/account_timeline_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/audit_log_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/billing_exception_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/bundle_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/bundle_timeline_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/catalog_attributes_simple.rb +3 -3
- data/lib/killbill_client/models/gen/credit_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/custom_field_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/deleted_event_subscription_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/direct_payment_attributes.rb +45 -0
- data/lib/killbill_client/models/gen/direct_transaction_attributes.rb +47 -0
- data/lib/killbill_client/models/gen/event_subscription_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/{chargeback_attributes.rb → gateway_notification_attributes.rb} +9 -12
- data/lib/killbill_client/models/gen/{refund_attributes.rb → hosted_payment_page_billing_address_attributes.rb} +10 -14
- data/lib/killbill_client/models/gen/hosted_payment_page_customer_attributes.rb +36 -0
- data/lib/killbill_client/models/gen/hosted_payment_page_fields_attributes.rb +33 -0
- data/lib/killbill_client/models/gen/hosted_payment_page_form_descriptor_attributes.rb +37 -0
- data/lib/killbill_client/models/gen/invoice_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/invoice_email_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/invoice_item_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/invoice_payment_attributes.rb +46 -0
- data/lib/killbill_client/models/gen/invoice_payment_transaction_attributes.rb +49 -0
- data/lib/killbill_client/models/gen/new_event_subscription_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/notification_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/overdue_state_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/payment_attributes.rb +11 -16
- data/lib/killbill_client/models/gen/payment_method_attributes.rb +4 -3
- data/lib/killbill_client/models/gen/payment_method_plugin_detail_attributes.rb +3 -15
- data/lib/killbill_client/models/gen/payment_transaction_attributes.rb +47 -0
- data/lib/killbill_client/models/gen/phase_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/plan_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/plan_detail_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/{payment_method_properties.rb → plugin_property_attributes.rb} +4 -4
- data/lib/killbill_client/models/gen/price_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/product_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/require_gen.rb +12 -6
- data/lib/killbill_client/models/gen/session_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/stack_trace_element_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/subject_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/subscription_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/tag_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/tag_definition_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/tenant_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/tenant_key_attributes.rb +3 -3
- data/lib/killbill_client/models/gen/usage_attributes.rb +3 -3
- data/lib/killbill_client/models/helpers/custom_field_helper.rb +51 -0
- data/lib/killbill_client/models/helpers/tag_helper.rb +112 -0
- data/lib/killbill_client/models/invoice.rb +30 -13
- data/lib/killbill_client/models/invoice_item.rb +37 -5
- data/lib/killbill_client/models/invoice_payment.rb +67 -0
- data/lib/killbill_client/models/models.rb +10 -2
- data/lib/killbill_client/models/payment.rb +5 -32
- data/lib/killbill_client/models/payment_method.rb +5 -6
- data/lib/killbill_client/models/phase.rb +9 -0
- data/lib/killbill_client/models/plan.rb +9 -0
- data/lib/killbill_client/models/plan_detail.rb +9 -0
- data/lib/killbill_client/models/product.rb +9 -0
- data/lib/killbill_client/models/resource.rb +22 -5
- data/lib/killbill_client/models/subscription.rb +28 -30
- data/lib/killbill_client/models/tag.rb +7 -11
- data/lib/killbill_client/models/tag_definition.rb +27 -6
- data/lib/killbill_client/models/transaction.rb +104 -0
- data/lib/killbill_client/version.rb +1 -1
- data/spec/killbill_client/remote/api_spec.rb +1 -1
- data/spec/killbill_client/remote/model_spec.rb +38 -23
- data/spec/killbill_client/resource_spec.rb +18 -0
- data/spec/spec_helper.rb +12 -0
- metadata +36 -19
- data/lib/killbill_client/models/chargeback.rb +0 -36
- data/lib/killbill_client/models/refund.rb +0 -55
@@ -0,0 +1,47 @@
|
|
1
|
+
###################################################################################
|
2
|
+
# #
|
3
|
+
# Copyright 2010-2013 Ning, Inc. #
|
4
|
+
# Copyright 2014 The Billing Project, LLC #
|
5
|
+
# #
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
|
+
# #
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
|
+
# #
|
12
|
+
# Unless required by applicable law or agreed to in writing, software #
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
|
15
|
+
# License for the specific language governing permissions and limitations #
|
16
|
+
# under the License. #
|
17
|
+
# #
|
18
|
+
###################################################################################
|
19
|
+
|
20
|
+
|
21
|
+
#
|
22
|
+
# DO NOT EDIT!!!
|
23
|
+
# File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
|
24
|
+
#
|
25
|
+
|
26
|
+
|
27
|
+
module KillBillClient
|
28
|
+
module Model
|
29
|
+
class PaymentTransactionAttributes < Resource
|
30
|
+
attribute :transaction_id
|
31
|
+
attribute :transaction_external_key
|
32
|
+
attribute :payment_id
|
33
|
+
attribute :payment_external_key
|
34
|
+
attribute :transaction_type
|
35
|
+
attribute :amount
|
36
|
+
attribute :currency
|
37
|
+
attribute :effective_date
|
38
|
+
attribute :status
|
39
|
+
attribute :gateway_error_code
|
40
|
+
attribute :gateway_error_msg
|
41
|
+
attribute :first_payment_reference_id
|
42
|
+
attribute :second_payment_reference_id
|
43
|
+
attribute :properties
|
44
|
+
attribute :audit_logs
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
data/lib/killbill_client/models/gen/{payment_method_properties.rb → plugin_property_attributes.rb}
RENAMED
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
module KillBillClient
|
28
28
|
module Model
|
29
|
-
class
|
29
|
+
class PluginPropertyAttributes < Resource
|
30
30
|
attribute :key
|
31
31
|
attribute :value
|
32
32
|
attribute :is_updatable
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
@@ -37,20 +37,26 @@ require 'killbill_client/models/gen/plan_attributes'
|
|
37
37
|
require 'killbill_client/models/gen/phase_attributes'
|
38
38
|
require 'killbill_client/models/gen/price_attributes'
|
39
39
|
require 'killbill_client/models/gen/catalog_attributes_simple'
|
40
|
-
require 'killbill_client/models/gen/chargeback_attributes'
|
41
40
|
require 'killbill_client/models/gen/credit_attributes'
|
42
41
|
require 'killbill_client/models/gen/custom_field_attributes'
|
42
|
+
require 'killbill_client/models/gen/gateway_notification_attributes'
|
43
|
+
require 'killbill_client/models/gen/hosted_payment_page_billing_address_attributes'
|
44
|
+
require 'killbill_client/models/gen/hosted_payment_page_customer_attributes'
|
45
|
+
require 'killbill_client/models/gen/hosted_payment_page_fields_attributes'
|
46
|
+
require 'killbill_client/models/gen/hosted_payment_page_form_descriptor_attributes'
|
43
47
|
require 'killbill_client/models/gen/invoice_email_attributes'
|
44
48
|
require 'killbill_client/models/gen/invoice_item_attributes'
|
45
49
|
require 'killbill_client/models/gen/invoice_attributes'
|
50
|
+
require 'killbill_client/models/gen/invoice_payment_attributes'
|
51
|
+
require 'killbill_client/models/gen/invoice_payment_transaction_attributes'
|
46
52
|
require 'killbill_client/models/gen/notification_attributes'
|
47
53
|
require 'killbill_client/models/gen/overdue_state_attributes'
|
48
54
|
require 'killbill_client/models/gen/payment_attributes'
|
49
55
|
require 'killbill_client/models/gen/payment_method_plugin_detail_attributes'
|
50
|
-
require 'killbill_client/models/gen/payment_method_properties'
|
51
56
|
require 'killbill_client/models/gen/payment_method_attributes'
|
57
|
+
require 'killbill_client/models/gen/payment_transaction_attributes'
|
52
58
|
require 'killbill_client/models/gen/plan_detail_attributes'
|
53
|
-
require 'killbill_client/models/gen/
|
59
|
+
require 'killbill_client/models/gen/plugin_property_attributes'
|
54
60
|
require 'killbill_client/models/gen/session_attributes'
|
55
61
|
require 'killbill_client/models/gen/subject_attributes'
|
56
62
|
require 'killbill_client/models/gen/event_subscription_attributes'
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Copyright 2010-2013 Ning, Inc. #
|
4
4
|
# Copyright 2014 The Billing Project, LLC #
|
5
5
|
# #
|
6
|
-
#
|
7
|
-
# (the "License"); you may not use this file except in
|
8
|
-
# License. You may obtain a copy of the License at:
|
6
|
+
# The Billing Project licenses this file to you under the Apache License, #
|
7
|
+
# version 2.0 (the "License"); you may not use this file except in #
|
8
|
+
# compliance with the License. You may obtain a copy of the License at: #
|
9
9
|
# #
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
11
11
|
# #
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module KillBillClient
|
2
|
+
module Model
|
3
|
+
module CustomFieldHelper
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def has_custom_fields(url_prefix, id_alias)
|
7
|
+
define_method('custom_fields') do |audit = 'NONE', options = {}|
|
8
|
+
self.class.get "#{url_prefix}/#{send(id_alias)}/customFields",
|
9
|
+
{
|
10
|
+
:audit => audit
|
11
|
+
},
|
12
|
+
options,
|
13
|
+
CustomField
|
14
|
+
end
|
15
|
+
|
16
|
+
define_method('add_custom_field') do |custom_fields, user = nil, reason = nil, comment = nil, options = {}|
|
17
|
+
body = custom_fields.is_a?(Enumerable) ? custom_fields : [custom_fields]
|
18
|
+
custom_field = self.class.post "#{url_prefix}/#{send(id_alias)}/customFields",
|
19
|
+
body.to_json,
|
20
|
+
{},
|
21
|
+
{
|
22
|
+
:user => user,
|
23
|
+
:reason => reason,
|
24
|
+
:comment => comment,
|
25
|
+
}.merge(options),
|
26
|
+
CustomField
|
27
|
+
custom_field.refresh(options)
|
28
|
+
end
|
29
|
+
|
30
|
+
define_method('remove_custom_field') do |custom_fields, user = nil, reason = nil, comment = nil, options = {}|
|
31
|
+
custom_fields_param = custom_fields.is_a?(Enumerable) ? custom_fields.join(",") : custom_fields
|
32
|
+
self.class.delete "#{url_prefix}/#{send(id_alias)}/customFields",
|
33
|
+
{},
|
34
|
+
{
|
35
|
+
:customFieldList => custom_fields_param
|
36
|
+
},
|
37
|
+
{
|
38
|
+
:user => user,
|
39
|
+
:reason => reason,
|
40
|
+
:comment => comment,
|
41
|
+
}.merge(options)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.included(klass)
|
47
|
+
klass.extend ClassMethods
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module KillBillClient
|
2
|
+
module Model
|
3
|
+
module TagHelper
|
4
|
+
|
5
|
+
AUTO_PAY_OFF_ID = '00000000-0000-0000-0000-000000000001'
|
6
|
+
AUTO_INVOICING_ID = '00000000-0000-0000-0000-000000000002'
|
7
|
+
OVERDUE_ENFORCEMENT_OFF_ID = '00000000-0000-0000-0000-000000000003'
|
8
|
+
WRITTEN_OFF_ID = '00000000-0000-0000-0000-000000000004'
|
9
|
+
MANUAL_PAY_ID = '00000000-0000-0000-0000-000000000005'
|
10
|
+
TEST_ID = '00000000-0000-0000-0000-000000000006'
|
11
|
+
|
12
|
+
def add_tag(tag_name, user = nil, reason = nil, comment = nil, options = {})
|
13
|
+
tag_definition = TagDefinition.find_by_name(tag_name, 'NONE', options)
|
14
|
+
if tag_definition.nil?
|
15
|
+
tag_definition = TagDefinition.new
|
16
|
+
tag_definition.name = tag_name
|
17
|
+
tag_definition.description = 'TagDefinition automatically created by the Kill Bill Ruby client library'
|
18
|
+
tag_definition = TagDefinition.create(user, options)
|
19
|
+
end
|
20
|
+
|
21
|
+
add_tag_from_definition_id(tag_definition.id, user, reason, comment, options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def remove_tag(tag_name, user = nil, reason = nil, comment = nil, options = {})
|
25
|
+
tag_definition = TagDefinition.find_by_name(tag_name, 'NONE', options)
|
26
|
+
return nil if tag_definition.nil?
|
27
|
+
|
28
|
+
remove_tag_from_definition_id(tag_definition.id, user, reason, comment, options)
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_tags(tag_definition_ids, user = nil, reason = nil, comment = nil, options = {})
|
32
|
+
current_tag_definition_ids = tags(false, 'NONE', options).map { |tag| tag.tag_definition_id }
|
33
|
+
|
34
|
+
# Find tags to remove
|
35
|
+
tags_to_remove = Set.new
|
36
|
+
current_tag_definition_ids.each do |current_tag_definition_id|
|
37
|
+
tags_to_remove << current_tag_definition_id unless tag_definition_ids.include?(current_tag_definition_id)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Find tags to add
|
41
|
+
tags_to_add = Set.new
|
42
|
+
tag_definition_ids.each do |new_tag_definition_id|
|
43
|
+
tags_to_add << new_tag_definition_id unless current_tag_definition_ids.include?(new_tag_definition_id)
|
44
|
+
end
|
45
|
+
|
46
|
+
remove_tags_from_definition_ids(tags_to_remove.to_a, user, reason, comment, options) unless tags_to_remove.empty?
|
47
|
+
add_tags_from_definition_ids(tags_to_add.to_a, user, reason, comment, options) unless tags_to_add.empty?
|
48
|
+
end
|
49
|
+
|
50
|
+
def add_tag_from_definition_id(tag_definition_id, user = nil, reason = nil, comment = nil, options = {})
|
51
|
+
add_tags_from_definition_ids([tag_definition_id], user, reason, comment, options)
|
52
|
+
end
|
53
|
+
|
54
|
+
def remove_tag_from_definition_id(tag_definition_id, user = nil, reason = nil, comment = nil, options = {})
|
55
|
+
remove_tags_from_definition_ids([tag_definition_id], user, reason, comment, options)
|
56
|
+
end
|
57
|
+
|
58
|
+
def control_tag_off?(control_tag_definition_id, options)
|
59
|
+
res = tags('NONE', options)
|
60
|
+
!((res || []).select do |t|
|
61
|
+
t.tag_definition_id == control_tag_definition_id
|
62
|
+
end.first.nil?)
|
63
|
+
end
|
64
|
+
|
65
|
+
module ClassMethods
|
66
|
+
def has_tags(url_prefix, id_alias)
|
67
|
+
define_method('tags') do |included_deleted = false, audit = 'NONE', options = {}|
|
68
|
+
self.class.get "#{url_prefix}/#{send(id_alias)}/tags",
|
69
|
+
{
|
70
|
+
:includedDeleted => included_deleted,
|
71
|
+
:audit => audit
|
72
|
+
},
|
73
|
+
options,
|
74
|
+
Tag
|
75
|
+
end
|
76
|
+
|
77
|
+
define_method('add_tags_from_definition_ids') do |tag_definition_ids, user = nil, reason = nil, comment = nil, options = {}|
|
78
|
+
created_tag = self.class.post "#{url_prefix}/#{send(id_alias)}/tags",
|
79
|
+
{},
|
80
|
+
{
|
81
|
+
:tagList => tag_definition_ids.join(',')
|
82
|
+
},
|
83
|
+
{
|
84
|
+
:user => user,
|
85
|
+
:reason => reason,
|
86
|
+
:comment => comment,
|
87
|
+
}.merge(options),
|
88
|
+
Tag
|
89
|
+
created_tag.refresh(options)
|
90
|
+
end
|
91
|
+
|
92
|
+
define_method('remove_tags_from_definition_ids') do |tag_definition_ids, user = nil, reason = nil, comment = nil, options = {}|
|
93
|
+
self.class.delete "#{url_prefix}/#{send(id_alias)}/tags",
|
94
|
+
{},
|
95
|
+
{
|
96
|
+
:tagList => tag_definition_ids.join(',')
|
97
|
+
},
|
98
|
+
{
|
99
|
+
:user => user,
|
100
|
+
:reason => reason,
|
101
|
+
:comment => comment,
|
102
|
+
}.merge(options)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.included(klass)
|
108
|
+
klass.extend ClassMethods
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -14,7 +14,7 @@ module KillBillClient
|
|
14
14
|
get "#{KILLBILL_API_INVOICES_PREFIX}/#{id_or_number}",
|
15
15
|
{
|
16
16
|
:withItems => with_items,
|
17
|
-
:audit
|
17
|
+
:audit => audit
|
18
18
|
},
|
19
19
|
options
|
20
20
|
end
|
@@ -23,7 +23,7 @@ module KillBillClient
|
|
23
23
|
get "#{KILLBILL_API_INVOICES_PREFIX}/#{Resource::KILLBILL_API_PAGINATION_PREFIX}",
|
24
24
|
{
|
25
25
|
:offset => offset,
|
26
|
-
:limit
|
26
|
+
:limit => limit
|
27
27
|
},
|
28
28
|
options
|
29
29
|
end
|
@@ -32,26 +32,34 @@ module KillBillClient
|
|
32
32
|
get "#{KILLBILL_API_INVOICES_PREFIX}/search/#{search_key}",
|
33
33
|
{
|
34
34
|
:offset => offset,
|
35
|
-
:limit
|
35
|
+
:limit => limit
|
36
36
|
},
|
37
37
|
options
|
38
38
|
end
|
39
39
|
|
40
|
+
def as_html(invoice_id, options = {})
|
41
|
+
get "#{KILLBILL_API_INVOICES_PREFIX}/#{invoice_id}/html",
|
42
|
+
{},
|
43
|
+
{
|
44
|
+
:accept => 'text/html'
|
45
|
+
}.merge(options)
|
46
|
+
end
|
47
|
+
|
40
48
|
def trigger_invoice(account_id, target_date, dry_run, user = nil, reason = nil, comment = nil, options = {})
|
41
|
-
query_map
|
49
|
+
query_map = {:accountId => account_id}
|
42
50
|
query_map[:targetDate] = target_date if !target_date.nil?
|
43
|
-
query_map[:dryRun]
|
51
|
+
query_map[:dryRun] = dry_run if !dry_run.nil?
|
44
52
|
|
45
53
|
begin
|
46
54
|
res = post "#{KILLBILL_API_INVOICES_PREFIX}",
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
+
{},
|
56
|
+
query_map,
|
57
|
+
{
|
58
|
+
:user => user,
|
59
|
+
:reason => reason,
|
60
|
+
:comment => comment,
|
61
|
+
}.merge(options),
|
62
|
+
Invoice
|
55
63
|
|
56
64
|
res.refresh(options)
|
57
65
|
|
@@ -59,7 +67,16 @@ module KillBillClient
|
|
59
67
|
# No invoice to generate : TODO parse json to verify this is indeed the case
|
60
68
|
end
|
61
69
|
end
|
70
|
+
end
|
62
71
|
|
72
|
+
def payments(with_plugin_info = false, audit = 'NONE', options = {})
|
73
|
+
self.class.get "#{KILLBILL_API_INVOICES_PREFIX}/#{invoice_id}/payments",
|
74
|
+
{
|
75
|
+
:withPluginInfo => with_plugin_info,
|
76
|
+
:audit => audit
|
77
|
+
},
|
78
|
+
options,
|
79
|
+
InvoicePayment
|
63
80
|
end
|
64
81
|
end
|
65
82
|
end
|
@@ -5,15 +5,47 @@ module KillBillClient
|
|
5
5
|
has_many :audit_logs, KillBillClient::Model::AuditLog
|
6
6
|
|
7
7
|
def create(user = nil, reason = nil, comment = nil, options = {})
|
8
|
-
created_invoice_item = self.class.post "#{Invoice::KILLBILL_API_INVOICES_PREFIX}/charges",
|
9
|
-
to_json,
|
8
|
+
created_invoice_item = self.class.post "#{Invoice::KILLBILL_API_INVOICES_PREFIX}/charges/#{account_id}",
|
9
|
+
[to_hash].to_json,
|
10
10
|
{},
|
11
11
|
{
|
12
|
-
:user
|
13
|
-
:reason
|
12
|
+
:user => user,
|
13
|
+
:reason => reason,
|
14
14
|
:comment => comment,
|
15
15
|
}.merge(options)
|
16
|
-
created_invoice_item.refresh(options, Invoice)
|
16
|
+
created_invoice_item.first.refresh(options, Invoice)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Adjust an invoice item
|
20
|
+
#
|
21
|
+
# Required: account_id, invoice_id, invoice_item_id
|
22
|
+
# Optional: amount, currency
|
23
|
+
def update(user = nil, reason = nil, comment = nil, options = {})
|
24
|
+
adjusted_invoice_item = self.class.post "#{Invoice::KILLBILL_API_INVOICES_PREFIX}/#{invoice_id}",
|
25
|
+
to_json,
|
26
|
+
{},
|
27
|
+
{
|
28
|
+
:user => user,
|
29
|
+
:reason => reason,
|
30
|
+
:comment => comment,
|
31
|
+
}.merge(options)
|
32
|
+
adjusted_invoice_item.refresh(options, Invoice)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Delete CBA
|
36
|
+
#
|
37
|
+
# Required: invoice_id, invoice_item_id
|
38
|
+
def delete(user = nil, reason = nil, comment = nil, options = {})
|
39
|
+
self.class.delete "#{Invoice::KILLBILL_API_INVOICES_PREFIX}/#{invoice_id}/#{invoice_item_id}/cba",
|
40
|
+
to_json,
|
41
|
+
{
|
42
|
+
:accountId => account_id
|
43
|
+
},
|
44
|
+
{
|
45
|
+
:user => user,
|
46
|
+
:reason => reason,
|
47
|
+
:comment => comment,
|
48
|
+
}.merge(options)
|
17
49
|
end
|
18
50
|
end
|
19
51
|
end
|