killbill 1.0.19 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. data/Jarfile +4 -2
  2. data/VERSION +1 -1
  3. data/killbill.gemspec +4 -3
  4. data/lib/killbill.rb +7 -51
  5. data/lib/killbill/creator.rb +10 -18
  6. data/lib/killbill/gen/account.rb +208 -27
  7. data/lib/killbill/gen/account_api_exception.rb +66 -0
  8. data/lib/killbill/gen/account_data.rb +166 -23
  9. data/lib/killbill/gen/account_email.rb +80 -8
  10. data/lib/killbill/gen/account_service.rb +55 -0
  11. data/lib/killbill/gen/account_user_api.rb +187 -0
  12. data/lib/killbill/gen/audit_user_api.rb +196 -0
  13. data/lib/killbill/gen/beatrix_service.rb +55 -0
  14. data/lib/killbill/gen/billing_exception_base.rb +66 -0
  15. data/lib/killbill/gen/blockable.rb +91 -0
  16. data/lib/killbill/gen/blocking_api_exception.rb +66 -0
  17. data/lib/killbill/gen/blocking_state.rb +150 -16
  18. data/lib/killbill/gen/call_context.rb +107 -13
  19. data/lib/killbill/gen/catalog.rb +76 -0
  20. data/lib/killbill/gen/catalog_api_exception.rb +66 -0
  21. data/lib/killbill/gen/catalog_service.rb +69 -0
  22. data/lib/killbill/gen/catalog_user_api.rb +54 -0
  23. data/lib/killbill/gen/column_info.rb +67 -0
  24. data/lib/killbill/gen/control_tag.rb +112 -0
  25. data/lib/killbill/gen/currency_value_null.rb +66 -0
  26. data/lib/killbill/gen/custom_field.rb +93 -10
  27. data/lib/killbill/gen/custom_field_api_exception.rb +66 -0
  28. data/lib/killbill/gen/custom_field_user_api.rb +115 -0
  29. data/lib/killbill/gen/database_export_output_stream.rb +51 -0
  30. data/lib/killbill/gen/default_mutable_account_data.rb +180 -0
  31. data/lib/killbill/gen/duration.rb +62 -0
  32. data/lib/killbill/gen/entitlement_service.rb +55 -0
  33. data/lib/killbill/gen/entitlement_user_api.rb +272 -0
  34. data/lib/killbill/gen/entitlement_user_api_exception.rb +66 -0
  35. data/lib/killbill/gen/entity.rb +84 -0
  36. data/lib/killbill/gen/entity_persistence_exception.rb +66 -0
  37. data/lib/killbill/gen/export_user_api.rb +17 -0
  38. data/lib/killbill/gen/ext_bus_event.rb +68 -9
  39. data/lib/killbill/gen/external_bus.rb +51 -0
  40. data/lib/killbill/gen/illegal_plan_change.rb +66 -0
  41. data/lib/killbill/gen/international_price.rb +79 -0
  42. data/lib/killbill/gen/invalid_config_exception.rb +49 -0
  43. data/lib/killbill/gen/invoice.rb +238 -23
  44. data/lib/killbill/gen/invoice_api_exception.rb +66 -0
  45. data/lib/killbill/gen/invoice_creation_event.rb +51 -0
  46. data/lib/killbill/gen/invoice_item.rb +179 -21
  47. data/lib/killbill/gen/invoice_migration_api.rb +66 -0
  48. data/lib/killbill/gen/invoice_notifier.rb +51 -0
  49. data/lib/killbill/gen/invoice_payment.rb +135 -15
  50. data/lib/killbill/gen/invoice_payment_api.rb +208 -0
  51. data/lib/killbill/gen/invoice_service.rb +55 -0
  52. data/lib/killbill/gen/invoice_user_api.rb +461 -0
  53. data/lib/killbill/gen/junction_api.rb +60 -0
  54. data/lib/killbill/gen/limit.rb +68 -0
  55. data/lib/killbill/gen/listing.rb +63 -0
  56. data/lib/killbill/gen/migration_account_data.rb +228 -0
  57. data/lib/killbill/gen/migration_plan.rb +143 -0
  58. data/lib/killbill/gen/mutable_account_data.rb +182 -0
  59. data/lib/killbill/gen/no_op_payment_plugin_api.rb +254 -0
  60. data/lib/killbill/gen/payment.rb +183 -20
  61. data/lib/killbill/gen/payment_api.rb +433 -0
  62. data/lib/killbill/gen/payment_api_exception.rb +66 -0
  63. data/lib/killbill/gen/payment_attempt.rb +100 -10
  64. data/lib/killbill/gen/payment_info_plugin.rb +103 -12
  65. data/lib/killbill/gen/payment_method.rb +116 -0
  66. data/lib/killbill/gen/payment_method_info_plugin.rb +64 -7
  67. data/lib/killbill/gen/payment_method_kv_info.rb +56 -6
  68. data/lib/killbill/gen/payment_method_plugin.rb +142 -20
  69. data/lib/killbill/gen/payment_plugin_api.rb +232 -0
  70. data/lib/killbill/gen/payment_plugin_api_exception.rb +59 -0
  71. data/lib/killbill/gen/payment_service.rb +62 -0
  72. data/lib/killbill/gen/plan.rb +143 -0
  73. data/lib/killbill/gen/plan_change_result.rb +68 -0
  74. data/lib/killbill/gen/plan_phase.rb +104 -0
  75. data/lib/killbill/gen/plan_phase_specifier.rb +80 -0
  76. data/lib/killbill/gen/plan_specifier.rb +73 -0
  77. data/lib/killbill/gen/price.rb +67 -0
  78. data/lib/killbill/gen/price_list.rb +74 -0
  79. data/lib/killbill/gen/price_list_set.rb +56 -0
  80. data/lib/killbill/gen/product.rb +101 -0
  81. data/lib/killbill/gen/record_id_api.rb +55 -0
  82. data/lib/killbill/gen/refund.rb +126 -13
  83. data/lib/killbill/gen/refund_info_plugin.rb +96 -10
  84. data/lib/killbill/gen/require_gen.rb +97 -15
  85. data/lib/killbill/gen/static_catalog.rb +137 -0
  86. data/lib/killbill/gen/subscription.rb +258 -28
  87. data/lib/killbill/gen/subscription_bundle.rb +94 -10
  88. data/lib/killbill/gen/subscription_status_dry_run.rb +89 -0
  89. data/lib/killbill/gen/subscription_transition.rb +196 -0
  90. data/lib/killbill/gen/tag.rb +88 -9
  91. data/lib/killbill/gen/tag_api_exception.rb +66 -0
  92. data/lib/killbill/gen/tag_definition.rb +110 -10
  93. data/lib/killbill/gen/tag_definition_api_exception.rb +66 -0
  94. data/lib/killbill/gen/tag_user_api.rb +239 -0
  95. data/lib/killbill/gen/tenant.rb +102 -0
  96. data/lib/killbill/gen/tenant_api_exception.rb +66 -0
  97. data/lib/killbill/gen/tenant_context.rb +39 -4
  98. data/lib/killbill/gen/tenant_data.rb +67 -0
  99. data/lib/killbill/gen/tenant_kv.rb +96 -0
  100. data/lib/killbill/gen/tenant_service.rb +55 -0
  101. data/lib/killbill/gen/tenant_user_api.rb +127 -0
  102. data/lib/killbill/gen/unit.rb +55 -0
  103. data/lib/killbill/jnotification.rb +1 -1
  104. data/lib/killbill/jpayment.rb +10 -7
  105. data/lib/killbill/jplugin.rb +63 -61
  106. data/lib/killbill/killbill_api.rb +42 -9
  107. data/spec/killbill/jnotification_spec.rb +15 -1
  108. data/spec/killbill/jpayment_spec.rb +12 -8
  109. data/spec/killbill/killbillapi_spec.rb +23 -21
  110. data/spec/killbill/payment_plugin_spec.rb +1 -9
  111. data/spec/killbill/payment_test.rb +21 -5
  112. metadata +96 -22
  113. data/lib/killbill/gen/audit_log.rb +0 -28
  114. data/lib/killbill/gen/call_origin.rb +0 -34
  115. data/lib/killbill/gen/currency.rb +0 -34
  116. data/lib/killbill/gen/date_time_zone.rb +0 -35
  117. data/lib/killbill/gen/ext_bus_event_type.rb +0 -34
  118. data/lib/killbill/gen/invoice_payment_type.rb +0 -34
  119. data/lib/killbill/gen/object_type.rb +0 -34
  120. data/lib/killbill/gen/payment_plugin_status.rb +0 -34
  121. data/lib/killbill/gen/refund_plugin_status.rb +0 -34
  122. data/lib/killbill/gen/subscription_source_type.rb +0 -34
  123. data/lib/killbill/gen/subscription_state.rb +0 -34
  124. data/lib/killbill/gen/user_type.rb +0 -34
  125. data/lib/killbill/gen/uuid.rb +0 -22
  126. data/lib/killbill/jconverter.rb +0 -537
  127. data/lib/killbill/jkillbill_api.rb +0 -137
  128. data/spec/killbill/jconverter_spec.rb +0 -193
@@ -1,34 +0,0 @@
1
-
2
- #
3
- # Ruby classes automatically generated from java classes-- don't edit
4
- #
5
- module Killbill
6
- module Plugin
7
- module Model
8
-
9
- class CallOrigin
10
-
11
- @@admissible_values = [:INTERNAL, :EXTERNAL, :TEST]
12
- attr_reader :enum
13
-
14
- def initialize(value)
15
- raise ArgumentError.new("Enum CallOrigin does not have such value : #{value}") if ! CallOrigin.is_admissible_value?(value)
16
- @enum = value
17
- end
18
-
19
- def ==(other)
20
- return false if other.nil?
21
- self.enum == other.enum
22
- end
23
-
24
- def self.is_admissible_value?(value)
25
- @@admissible_values.include?(value)
26
- end
27
-
28
- def self.admissible_values
29
- @@admissible_values
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,34 +0,0 @@
1
-
2
- #
3
- # Ruby classes automatically generated from java classes-- don't edit
4
- #
5
- module Killbill
6
- module Plugin
7
- module Model
8
-
9
- class Currency
10
-
11
- @@admissible_values = [:GBP, :MXN, :BRL, :EUR, :AUD, :USD]
12
- attr_reader :enum
13
-
14
- def initialize(value)
15
- raise ArgumentError.new("Enum Currency does not have such value : #{value}") if ! Currency.is_admissible_value?(value)
16
- @enum = value
17
- end
18
-
19
- def ==(other)
20
- return false if other.nil?
21
- self.enum == other.enum
22
- end
23
-
24
- def self.is_admissible_value?(value)
25
- @@admissible_values.include?(value)
26
- end
27
-
28
- def self.admissible_values
29
- @@admissible_values
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,35 +0,0 @@
1
-
2
-
3
- #
4
- # TODO STEPH Should have been generated--- but not yet
5
- #
6
- module Killbill
7
- module Plugin
8
- module Model
9
-
10
- class DateTimeZone
11
-
12
- @@admissible_values = [:UTC]
13
- attr_reader :enum
14
-
15
- def initialize(value)
16
- raise ArgumentError.new("Enum DateTimeZone does not have such value : #{value}") if ! DateTimeZone.is_admissible_value?(value)
17
- @enum = value
18
- end
19
-
20
- def ==(other)
21
- return false if other.nil?
22
- self.enum == other.enum
23
- end
24
-
25
- def self.is_admissible_value?(value)
26
- @@admissible_values.include?(value)
27
- end
28
-
29
- def self.admissible_values
30
- @@admissible_values
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,34 +0,0 @@
1
-
2
- #
3
- # Ruby classes automatically generated from java classes-- don't edit
4
- #
5
- module Killbill
6
- module Plugin
7
- module Model
8
-
9
- class ExtBusEventType
10
-
11
- @@admissible_values = [:ACCOUNT_CREATION, :ACCOUNT_CHANGE, :SUBSCRIPTION_CREATION, :SUBSCRIPTION_PHASE, :SUBSCRIPTION_CHANGE, :SUBSCRIPTION_CANCEL, :SUBSCRIPTION_UNCANCEL, :OVERDUE_CHANGE, :INVOICE_CREATION, :INVOICE_ADJUSTMENT, :PAYMENT_SUCCESS, :PAYMENT_FAILED, :TAG_CREATION, :TAG_DELETION, :CUSTOM_FIELD_CREATION, :CUSTOM_FIELD_DELETION]
12
- attr_reader :enum
13
-
14
- def initialize(value)
15
- raise ArgumentError.new("Enum ExtBusEventType does not have such value : #{value}") if ! ExtBusEventType.is_admissible_value?(value)
16
- @enum = value
17
- end
18
-
19
- def ==(other)
20
- return false if other.nil?
21
- self.enum == other.enum
22
- end
23
-
24
- def self.is_admissible_value?(value)
25
- @@admissible_values.include?(value)
26
- end
27
-
28
- def self.admissible_values
29
- @@admissible_values
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,34 +0,0 @@
1
-
2
- #
3
- # Ruby classes automatically generated from java classes-- don't edit
4
- #
5
- module Killbill
6
- module Plugin
7
- module Model
8
-
9
- class InvoicePaymentType
10
-
11
- @@admissible_values = [:ATTEMPT, :CHARGED_BACK, :REFUND]
12
- attr_reader :enum
13
-
14
- def initialize(value)
15
- raise ArgumentError.new("Enum InvoicePaymentType does not have such value : #{value}") if ! InvoicePaymentType.is_admissible_value?(value)
16
- @enum = value
17
- end
18
-
19
- def ==(other)
20
- return false if other.nil?
21
- self.enum == other.enum
22
- end
23
-
24
- def self.is_admissible_value?(value)
25
- @@admissible_values.include?(value)
26
- end
27
-
28
- def self.admissible_values
29
- @@admissible_values
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,34 +0,0 @@
1
-
2
- #
3
- # Ruby classes automatically generated from java classes-- don't edit
4
- #
5
- module Killbill
6
- module Plugin
7
- module Model
8
-
9
- class ObjectType
10
-
11
- @@admissible_values = [:ACCOUNT, :ACCOUNT_EMAIL, :BLOCKING_STATES, :BUNDLE, :CUSTOM_FIELD, :INVOICE, :PAYMENT, :INVOICE_ITEM, :INVOICE_PAYMENT, :SUBSCRIPTION, :SUBSCRIPTION_EVENT, :PAYMENT_ATTEMPT, :PAYMENT_METHOD, :REFUND, :TAG, :TAG_DEFINITION, :TENANT, :TENANT_KVS]
12
- attr_reader :enum
13
-
14
- def initialize(value)
15
- raise ArgumentError.new("Enum ObjectType does not have such value : #{value}") if ! ObjectType.is_admissible_value?(value)
16
- @enum = value
17
- end
18
-
19
- def ==(other)
20
- return false if other.nil?
21
- self.enum == other.enum
22
- end
23
-
24
- def self.is_admissible_value?(value)
25
- @@admissible_values.include?(value)
26
- end
27
-
28
- def self.admissible_values
29
- @@admissible_values
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,34 +0,0 @@
1
-
2
- #
3
- # Ruby classes automatically generated from java classes-- don't edit
4
- #
5
- module Killbill
6
- module Plugin
7
- module Model
8
-
9
- class PaymentPluginStatus
10
-
11
- @@admissible_values = [:UNDEFINED, :PROCESSED, :ERROR]
12
- attr_reader :enum
13
-
14
- def initialize(value)
15
- raise ArgumentError.new("Enum PaymentPluginStatus does not have such value : #{value}") if ! PaymentPluginStatus.is_admissible_value?(value)
16
- @enum = value
17
- end
18
-
19
- def ==(other)
20
- return false if other.nil?
21
- self.enum == other.enum
22
- end
23
-
24
- def self.is_admissible_value?(value)
25
- @@admissible_values.include?(value)
26
- end
27
-
28
- def self.admissible_values
29
- @@admissible_values
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,34 +0,0 @@
1
-
2
- #
3
- # Ruby classes automatically generated from java classes-- don't edit
4
- #
5
- module Killbill
6
- module Plugin
7
- module Model
8
-
9
- class RefundPluginStatus
10
-
11
- @@admissible_values = [:UNDEFINED, :PROCESSED, :ERROR]
12
- attr_reader :enum
13
-
14
- def initialize(value)
15
- raise ArgumentError.new("Enum RefundPluginStatus does not have such value : #{value}") if ! RefundPluginStatus.is_admissible_value?(value)
16
- @enum = value
17
- end
18
-
19
- def ==(other)
20
- return false if other.nil?
21
- self.enum == other.enum
22
- end
23
-
24
- def self.is_admissible_value?(value)
25
- @@admissible_values.include?(value)
26
- end
27
-
28
- def self.admissible_values
29
- @@admissible_values
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,34 +0,0 @@
1
-
2
- #
3
- # Ruby classes automatically generated from java classes-- don't edit
4
- #
5
- module Killbill
6
- module Plugin
7
- module Model
8
-
9
- class SubscriptionSourceType
10
-
11
- @@admissible_values = [:NATIVE, :MIGRATED, :TRANSFERED]
12
- attr_reader :enum
13
-
14
- def initialize(value)
15
- raise ArgumentError.new("Enum SubscriptionSourceType does not have such value : #{value}") if ! SubscriptionSourceType.is_admissible_value?(value)
16
- @enum = value
17
- end
18
-
19
- def ==(other)
20
- return false if other.nil?
21
- self.enum == other.enum
22
- end
23
-
24
- def self.is_admissible_value?(value)
25
- @@admissible_values.include?(value)
26
- end
27
-
28
- def self.admissible_values
29
- @@admissible_values
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,34 +0,0 @@
1
-
2
- #
3
- # Ruby classes automatically generated from java classes-- don't edit
4
- #
5
- module Killbill
6
- module Plugin
7
- module Model
8
-
9
- class SubscriptionState
10
-
11
- @@admissible_values = [:ACTIVE, :CANCELLED]
12
- attr_reader :enum
13
-
14
- def initialize(value)
15
- raise ArgumentError.new("Enum SubscriptionState does not have such value : #{value}") if ! SubscriptionState.is_admissible_value?(value)
16
- @enum = value
17
- end
18
-
19
- def ==(other)
20
- return false if other.nil?
21
- self.enum == other.enum
22
- end
23
-
24
- def self.is_admissible_value?(value)
25
- @@admissible_values.include?(value)
26
- end
27
-
28
- def self.admissible_values
29
- @@admissible_values
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,34 +0,0 @@
1
-
2
- #
3
- # Ruby classes automatically generated from java classes-- don't edit
4
- #
5
- module Killbill
6
- module Plugin
7
- module Model
8
-
9
- class UserType
10
-
11
- @@admissible_values = [:SYSTEM, :ADMIN, :CUSTOMER, :MIGRATION, :TEST]
12
- attr_reader :enum
13
-
14
- def initialize(value)
15
- raise ArgumentError.new("Enum UserType does not have such value : #{value}") if ! UserType.is_admissible_value?(value)
16
- @enum = value
17
- end
18
-
19
- def ==(other)
20
- return false if other.nil?
21
- self.enum == other.enum
22
- end
23
-
24
- def self.is_admissible_value?(value)
25
- @@admissible_values.include?(value)
26
- end
27
-
28
- def self.admissible_values
29
- @@admissible_values
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,22 +0,0 @@
1
- #
2
- # TODO STEPH Should have been generated--- but not yet
3
- #
4
- module Killbill
5
- module Plugin
6
- module Model
7
-
8
- class UUID
9
-
10
- attr_reader :uuid
11
-
12
- def initialize(uuid)
13
- @uuid = uuid
14
- end
15
-
16
- def to_s
17
- @uuid.to_s
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,537 +0,0 @@
1
-
2
- require 'date'
3
-
4
- module Killbill
5
- module Plugin
6
-
7
- class JConverter
8
-
9
- class << self
10
-
11
- #
12
- # Convert from ruby -> java
13
- #
14
- def to_account(data)
15
- Killbill::Plugin::Model::Account.new(to_uuid(data.id),
16
- nil,
17
- to_joda_date_time(data.created_date),
18
- to_joda_date_time(data.updated_date),
19
- to_string(data.external_key),
20
- to_string(data.name),
21
- data.first_name_length,
22
- to_string(data.email),
23
- data.bill_cycle_day_local,
24
- to_currency(data.currency),
25
- to_uuid(data.payment_method_id),
26
- to_date_time_zone(data.time_zone),
27
- to_string(data.locale),
28
- to_string(data.address1),
29
- to_string(data.address2),
30
- to_string(data.company_name),
31
- to_string(data.city),
32
- to_string(data.state_or_province),
33
- to_string(data.postal_code),
34
- to_string(data.country),
35
- to_string(data.phone),
36
- to_boolean(data.is_migrated),
37
- to_boolean(data.is_notified_for_invoices))
38
- end
39
-
40
-
41
- def to_account_data(data)
42
- Killbill::Plugin::Model::AccountData.new(to_string(data.external_key),
43
- to_string(data.name),
44
- data.first_name_length,
45
- to_string(data.email),
46
- data.bill_cycle_day_local,
47
- to_currency(data.currency),
48
- to_uuid(data.payment_method_id),
49
- to_date_time_zone(data.time_zone),
50
- to_string(data.locale),
51
- to_string(data.address1),
52
- to_string(data.address2),
53
- to_string(data.company_name),
54
- to_string(data.city),
55
- to_string(data.state_or_province),
56
- to_string(data.postal_code),
57
- to_string(data.country),
58
- to_string(data.phone),
59
- to_boolean(data.is_migrated),
60
- to_boolean(data.is_notified_for_invoices))
61
- end
62
-
63
- def to_payment_info_plugin(payment_response)
64
- Killbill::Plugin::Model::PaymentInfoPlugin.new(to_big_decimal_with_cents_conversion(payment_response.amount),
65
- to_joda_date_time(payment_response.created_date),
66
- to_joda_date_time(payment_response.effective_date),
67
- to_payment_plugin_status(payment_response.status),
68
- to_string(payment_response.gateway_error),
69
- to_string(payment_response.gateway_error_code),
70
- to_string(payment_response.first_payment_reference_id),
71
- to_string(payment_response.second_payment_reference_id))
72
- end
73
-
74
- def to_refund_info_plugin(refund_response)
75
- Killbill::Plugin::Model::RefundInfoPlugin.new(to_big_decimal_with_cents_conversion(refund_response.amount),
76
- to_joda_date_time(refund_response.created_date),
77
- to_joda_date_time(refund_response.effective_date),
78
- to_refund_plugin_status(refund_response.status),
79
- to_string(refund_response.gateway_error),
80
- to_string(refund_response.gateway_error_code),
81
- to_string(refund_response.reference_id))
82
- end
83
-
84
- def to_payment_method_response(pm)
85
- props = java.util.ArrayList.new
86
- pm.properties.each do |p|
87
- jp = com.ning.billing.payment.api.PaymentMethodKVInfo.new(p.key, p.value, p.is_updatable)
88
- props.add(jp)
89
- end
90
- Killbill::Plugin::Model::PaymentMethodPlugin.new(to_string(pm.external_payment_method_id),
91
- to_boolean(pm.is_default_payment_method),
92
- props,
93
- nil,
94
- to_string(pm.type),
95
- to_string(pm.cc_name),
96
- to_string(pm.cc_type),
97
- to_string(pm.cc_expiration_month),
98
- to_string(pm.cc_expiration_year),
99
- to_string(pm.cc_last4),
100
- to_string(pm.address1),
101
- to_string(pm.address2),
102
- to_string(pm.city),
103
- to_string(pm.state),
104
- to_string(pm.zip),
105
- to_string(pm.country))
106
- end
107
-
108
- def to_payment_method_info_plugin(pm)
109
- Killbill::Plugin::Model::PaymentMethodInfoPlugin.new(to_uuid(pm.account_id),
110
- to_uuid(pm.payment_method_id),
111
- to_boolean(pm.is_default),
112
- to_string(pm.external_payment_method_id))
113
- end
114
-
115
-
116
- def to_uuid(uuid)
117
- uuid.nil? ? nil : java.util.UUID.fromString(uuid.to_s)
118
- end
119
-
120
- def to_joda_date_time(time)
121
- date_time = (time.kind_of? Time) ? DateTime.parse(time.to_s) : time
122
- date_time.nil? ? nil : org.joda.time.DateTime.new(date_time.to_s, org.joda.time.DateTimeZone::UTC)
123
- end
124
-
125
- def to_string(str)
126
- str.nil? ? nil : java.lang.String.new(str.to_s)
127
- end
128
-
129
-
130
- def to_currency(currency)
131
- if currency.nil?
132
- return nil
133
- end
134
- if currency.enum == :GBP
135
- return Java::com.ning.billing.catalog.api.Currency::GBP
136
- elsif currency.enum == :MXN
137
- return Java::com.ning.billing.catalog.api.Currency::MXN
138
- elsif currency.enum == :BRL
139
- return Java::com.ning.billing.catalog.api.Currency::BRL
140
- elsif currency.enum == :EUR
141
- return Java::com.ning.billing.catalog.api.Currency::EUR
142
- elsif currency.enum == :AUD
143
- return Java::com.ning.billing.catalog.api.Currency::AUD
144
- elsif currency.enum == :USD
145
- return Java::com.ning.billing.catalog.api.Currency::USD
146
- end
147
- nil
148
- end
149
-
150
-
151
- def to_date_time_zone(date_time_zone)
152
- if date_time_zone.nil?
153
- return nil
154
- end
155
- if date_time_zone.enum == :UTC
156
- return org.joda.time.DateTimeZone::UTC
157
- end
158
- nil
159
- end
160
-
161
-
162
- def to_payment_plugin_status(status)
163
- if status.enum == :PROCESSED
164
- Java::com.ning.billing.payment.plugin.api.PaymentPluginStatus::PROCESSED
165
- elsif status.enum == :ERROR
166
- Java::com.ning.billing.payment.plugin.api.PaymentPluginStatus::ERROR
167
- else
168
- Java::com.ning.billing.payment.plugin.api.PaymentPluginStatus::UNDEFINED
169
- end
170
- end
171
-
172
- def to_refund_plugin_status(status)
173
- if status.enum == :PROCESSED
174
- Java::com.ning.billing.payment.plugin.api.RefundPluginStatus::PROCESSED
175
- elsif status.enum == :ERROR
176
- Java::com.ning.billing.payment.plugin.api.RefundPluginStatus::ERROR
177
- else
178
- Java::com.ning.billing.payment.plugin.api.RefundPluginStatus::UNDEFINED
179
- end
180
- end
181
-
182
- def to_object_type(type)
183
- if type.enum == :ACCOUNT
184
- Java::com.ning.billing.ObjectType::ACCOUNT
185
- elsif type.enum == :ACCOUNT_EMAIL
186
- Java::com.ning.billing.ObjectType::ACCOUNT_EMAIL
187
- elsif type.enum == :BLOCKING_STATES
188
- Java::com.ning.billing.ObjectType::BLOCKING_STATES
189
- elsif type.enum == :BUNDLE
190
- Java::com.ning.billing.ObjectType::BUNDLE
191
- elsif type.enum == :CUSTOM_FIELD
192
- Java::com.ning.billing.ObjectType::CUSTOM_FIELD
193
- elsif type.enum == :INVOICE
194
- Java::com.ning.billing.ObjectType::INVOICE
195
- elsif type.enum == :PAYMENT
196
- Java::com.ning.billing.ObjectType::PAYMENT
197
- elsif type.enum == :INVOICE_ITEM
198
- Java::com.ning.billing.ObjectType::INVOICE_ITEM
199
- elsif type.enum == :INVOICE_PAYMENT
200
- Java::com.ning.billing.ObjectType::INVOICE_PAYMENT
201
- elsif type.enum == :SUBSCRIPTION
202
- Java::com.ning.billing.ObjectType::SUBSCRIPTION
203
- elsif type.enum == :SUBSCRIPTION_EVENT
204
- Java::com.ning.billing.ObjectType::SUBSCRIPTION_EVENT
205
- elsif type.enum == :PAYMENT_ATTEMPT
206
- Java::com.ning.billing.ObjectType::PAYMENT_ATTEMPT
207
- elsif type.enum == :PAYMENT_METHOD
208
- Java::com.ning.billing.ObjectType::PAYMENT_METHOD
209
- elsif type.enum == :REFUND
210
- Java::com.ning.billing.ObjectType::REFUND
211
- elsif type.enum == :TAG
212
- Java::com.ning.billing.ObjectType::TAG
213
- elsif type.enum == :TAG_DEFINITION
214
- Java::com.ning.billing.ObjectType::TAG_DEFINITION
215
- elsif type.enum == :TENANT
216
- Java::com.ning.billing.ObjectType::TENANT
217
- else # type.enum == :TENANT_KVS
218
- Java::com.ning.billing.ObjectType::TENANT_KVS
219
- end
220
- end
221
-
222
- def to_big_decimal_with_cents_conversion(amount_in_cents)
223
- amount_in_cents.nil? ? java.math.BigDecimal::ZERO : java.math.BigDecimal.new('%.2f' % (amount_in_cents.to_i/100.0))
224
- end
225
-
226
- def to_boolean(b)
227
- b.nil? ? java.lang.Boolean.new(false) : java.lang.Boolean.new(b)
228
- end
229
-
230
-
231
- #
232
- # Convert from java -> ruby
233
- #
234
-
235
-
236
- def from_account(data)
237
- Killbill::Plugin::Model::Account.new(from_uuid(data.id),
238
- nil,
239
- #from_blocking_state(data.blocking_state),
240
- from_joda_date_time(data.created_date),
241
- from_joda_date_time(data.updated_date),
242
- from_string(data.external_key),
243
- from_string(data.name),
244
- data.first_name_length,
245
- from_string(data.email),
246
- data.bill_cycle_day_local,
247
- from_currency(data.currency),
248
- from_uuid(data.payment_method_id),
249
- from_date_time_zone(data.time_zone),
250
- from_string(data.locale),
251
- from_string(data.address1),
252
- from_string(data.address2),
253
- from_string(data.company_name),
254
- from_string(data.city),
255
- from_string(data.state_or_province),
256
- from_string(data.postal_code),
257
- from_string(data.country),
258
- from_string(data.phone),
259
- from_boolean(data.is_migrated),
260
- from_boolean(data.is_notified_for_invoices))
261
- end
262
-
263
- def from_tag_definition(data)
264
- Killbill::Plugin::Model::TagDefinition.new(from_uuid(data.id),
265
- from_joda_date_time(data.created_date),
266
- from_joda_date_time(data.updated_date),
267
- from_string(data.name),
268
- from_string(data.description),
269
- from_boolean(data.is_control_tag),
270
- nil)
271
- end
272
-
273
- def from_blocking_state(data)
274
- if data.nil?
275
- return nil
276
- end
277
- end
278
-
279
-
280
- def from_tenant_context(context)
281
- return Killbill::Plugin::Model::TenantContext.new(from_uuid(context.tenant_id))
282
- end
283
-
284
- def from_call_context(context)
285
- return Killbill::Plugin::Model::CallContext.new(from_uuid(context.tenant_id),
286
- from_uuid(context.user_token),
287
- from_string(context.user_name),
288
- from_call_origin(context.call_origin),
289
- from_user_type(context.user_type),
290
- from_string(context.reason_code),
291
- from_string(context.comments),
292
- from_joda_date_time(context.created_date),
293
- from_joda_date_time(context.updated_date))
294
- end
295
-
296
-
297
- def from_uuid(uuid)
298
- uuid.nil? ? nil : Killbill::Plugin::Model::UUID.new(uuid.to_s)
299
- end
300
-
301
- def from_joda_date_time(joda_time)
302
- if joda_time.nil?
303
- return nil
304
- end
305
-
306
- fmt = org.joda.time.format.ISODateTimeFormat.date_time
307
- str = fmt.print(joda_time);
308
- DateTime.iso8601(str)
309
- end
310
-
311
- def from_string(str)
312
- str.nil? ? nil : str.to_s
313
- end
314
-
315
-
316
- def from_currency(currency)
317
- if currency.nil?
318
- return nil
319
- end
320
- if currency.to_s == Java::com.ning.billing.catalog.api.Currency::GBP.to_s
321
- return Killbill::Plugin::Model::Currency.new(:GBP)
322
- elsif currency.to_s == Java::com.ning.billing.catalog.api.Currency::MXN.to_s
323
- return Killbill::Plugin::Model::Currency.new(:MXN)
324
- elsif currency.to_s == Java::com.ning.billing.catalog.api.Currency::BRL.to_s
325
- return Killbill::Plugin::Model::Currency.new(:BRL)
326
- elsif currency.to_s == Java::com.ning.billing.catalog.api.Currency::EUR.to_s
327
- return Killbill::Plugin::Model::Currency.new(:EUR)
328
- elsif currency.to_s == Java::com.ning.billing.catalog.api.Currency::AUD.to_s
329
- return Killbill::Plugin::Model::Currency.new(:AUD)
330
- elsif currency.to_s == Java::com.ning.billing.catalog.api.Currency::USD.to_s
331
- return Killbill::Plugin::Model::Currency.new(:USD)
332
- end
333
- nil
334
- end
335
-
336
- def from_call_origin(origin)
337
- if origin.nil?
338
- return nil
339
- end
340
-
341
- if origin.to_s == Java::com.ning.billing.util.callcontext.CallOrigin::INTERNAL.to_s
342
- return Killbill::Plugin::Model::CallOrigin.new(:INTERNAL)
343
- elsif origin.to_s == Java::com.ning.billing.util.callcontext.CallOrigin::EXTERNAL.to_s
344
- return Killbill::Plugin::Model::CallOrigin.new(:EXTERNAL)
345
- else
346
- return Killbill::Plugin::Model::CallOrigin.new(:TEST)
347
- end
348
- end
349
-
350
- def from_user_type(user)
351
- if user.nil?
352
- return nil
353
- end
354
-
355
- if user.to_s == Java::com.ning.billing.util.callcontext.UserType::SYSTEM.to_s
356
- return Killbill::Plugin::Model::UserType.new(:SYSTEM)
357
- elsif user.to_s == Java::com.ning.billing.util.callcontext.UserType::ADMIN.to_s
358
- return Killbill::Plugin::Model::UserType.new(:ADMIN)
359
- elsif user.to_s == Java::com.ning.billing.util.callcontext.UserType::CUSTOMER.to_s
360
- return Killbill::Plugin::Model::UserType.new(:CUSTOMER)
361
- elsif user.to_s == Java::com.ning.billing.util.callcontext.UserType::MIGRATION.to_s
362
- return Killbill::Plugin::Model::UserType.new(:MIGRATION)
363
- else # user == Java::com.ning.billing.util.callcontext.UserType::TEST
364
- return Killbill::Plugin::Model::UserType.new(:TEST)
365
- end
366
- end
367
-
368
- def from_date_time_zone(date_time_zone)
369
- if date_time_zone.nil?
370
- return nil
371
- end
372
- if date_time_zone.to_s == org.joda.time.DateTimeZone::UTC.to_s
373
- return Killbill::Plugin::Model::DateTimeZone.new(:UTC)
374
- end
375
- nil
376
- end
377
-
378
-
379
- def from_payment_plugin_status(status)
380
- if status.to_s == Java::com.ning.billing.payment.plugin.api.PaymentPluginStatus::PROCESSED.to_s
381
- Killbill::Plugin::Model::PaymentPluginStatus.new(:PROCESSED)
382
- elsif status.to_s == Java::com.ning.billing.payment.plugin.api.PaymentPluginStatus::ERROR.to_s
383
- Killbill::Plugin::Model::PaymentPluginStatus.new(:ERROR)
384
- else
385
- Killbill::Plugin::Model::PaymentPluginStatus.new(:UNDEFINED)
386
- end
387
- end
388
-
389
- def from_refund_plugin_status(status)
390
- if status.to_s == Java::com.ning.billing.payment.plugin.api.RefundPluginStatus::PROCESSED.to_s
391
- Killbill::Plugin::Model::RefundPluginStatus.new(:PROCESSED)
392
- elsif status.to_s == Java::com.ning.billing.payment.plugin.api.RefundPluginStatus::ERROR.to_s
393
- Killbill::Plugin::Model::RefundPluginStatus.new(:ERROR)
394
- else
395
- Killbill::Plugin::Model::RefundPluginStatus.new(:UNDEFINED)
396
- end
397
- end
398
-
399
- def from_big_decimal_with_cents_conversion(big_decimal)
400
- big_decimal.nil? ? 0 : big_decimal.multiply(java.math.BigDecimal.valueOf(100)).to_s.to_i
401
- end
402
-
403
- def from_boolean(b)
404
- if b.nil?
405
- return false
406
- end
407
-
408
- b_value = (b.java_kind_of? java.lang.Boolean) ? b.boolean_value : b
409
- return b_value ? true : false
410
- end
411
-
412
- def from_payment_method_plugin(pm)
413
- props = Array.new
414
- pm.properties.each do |p|
415
- key = from_string(p.key)
416
- value = from_string(p.value)
417
- is_updatable = from_boolean(p.is_updatable)
418
- props << Killbill::Plugin::Model::PaymentMethodKVInfo.new(is_updatable, key, value)
419
- end
420
-
421
- pmid = from_string(pm.external_payment_method_id)
422
- default = from_boolean(pm.is_default_payment_method)
423
- Killbill::Plugin::Model::PaymentMethodPlugin.new(from_string(pm.external_payment_method_id),
424
- from_boolean(pm.is_default_payment_method),
425
- props,
426
- nil,
427
- from_string(pm.type),
428
- from_string(pm.cc_name),
429
- from_string(pm.cc_type),
430
- from_string(pm.cc_expiration_month),
431
- from_string(pm.cc_expiration_year),
432
- from_string(pm.cc_last4),
433
- from_string(pm.address1),
434
- from_string(pm.address2),
435
- from_string(pm.city),
436
- from_string(pm.state),
437
- from_string(pm.zip),
438
- from_string(pm.country))
439
- end
440
-
441
- def from_payment_method_info_plugin(pm)
442
- Killbill::Plugin::Model::PaymentMethodInfoPlugin.new(from_uuid(pm.account_id),
443
- from_uuid(pm.payment_method_id),
444
- from_boolean(pm.is_default),
445
- from_string(pm.external_payment_method_id))
446
- end
447
-
448
-
449
- def from_ext_bus_event(event)
450
- Killbill::Plugin::Model::ExtBusEvent.new(from_bus_event_type(event.event_type),
451
- from_object_type(event.object_type),
452
- from_uuid(event.object_id),
453
- from_uuid(event.account_id),
454
- from_uuid(event.tenant_id))
455
- end
456
-
457
- def from_object_type(type)
458
- if type.to_s == Java::com.ning.billing.ObjectType::ACCOUNT.to_s
459
- Killbill::Plugin::Model::ObjectType.new(:ACCOUNT)
460
- elsif type.to_s == Java::com.ning.billing.ObjectType::ACCOUNT_EMAIL.to_s
461
- Killbill::Plugin::Model::ObjectType.new(:ACCOUNT_EMAIL)
462
- elsif type.to_s == Java::com.ning.billing.ObjectType::BLOCKING_STATES.to_s
463
- Killbill::Plugin::Model::ObjectType.new(:BLOCKING_STATES)
464
- elsif type.to_s == Java::com.ning.billing.ObjectType::BUNDLE.to_s
465
- Killbill::Plugin::Model::ObjectType.new(:BUNDLE)
466
- elsif type.to_s == Java::com.ning.billing.ObjectType::CUSTOM_FIELD.to_s
467
- Killbill::Plugin::Model::ObjectType.new(:CUSTOM_FIELD)
468
- elsif type.to_s == Java::com.ning.billing.ObjectType::INVOICE.to_s
469
- Killbill::Plugin::Model::ObjectType.new(:INVOICE)
470
- elsif type.to_s == Java::com.ning.billing.ObjectType::PAYMENT.to_s
471
- Killbill::Plugin::Model::ObjectType.new(:PAYMENT)
472
- elsif type.to_s == Java::com.ning.billing.ObjectType::INVOICE_ITEM.to_s
473
- Killbill::Plugin::Model::ObjectType.new(:INVOICE_ITEM)
474
- elsif type.to_s == Java::com.ning.billing.ObjectType::INVOICE_PAYMENT.to_s
475
- Killbill::Plugin::Model::ObjectType.new(:INVOICE_PAYMENT)
476
- elsif type.to_s == Java::com.ning.billing.ObjectType::SUBSCRIPTION.to_s
477
- Killbill::Plugin::Model::ObjectType.new(:SUBSCRIPTION)
478
- elsif type.to_s == Java::com.ning.billing.ObjectType::SUBSCRIPTION_EVENT.to_s
479
- Killbill::Plugin::Model::ObjectType.new(:SUBSCRIPTION_EVENT)
480
- elsif type.to_s == Java::com.ning.billing.ObjectType::PAYMENT_ATTEMPT.to_s
481
- Killbill::Plugin::Model::ObjectType.new(:PAYMENT_ATTEMPT)
482
- elsif type.to_s == Java::com.ning.billing.ObjectType::PAYMENT_METHOD.to_s
483
- Killbill::Plugin::Model::ObjectType.new(:PAYMENT_METHOD)
484
- elsif type.to_s == Java::com.ning.billing.ObjectType::REFUND.to_s
485
- Killbill::Plugin::Model::ObjectType.new(:REFUND)
486
- elsif type.to_s == Java::com.ning.billing.ObjectType::TAG.to_s
487
- Killbill::Plugin::Model::ObjectType.new(:TAG)
488
- elsif type.to_s == Java::com.ning.billing.ObjectType::TAG_DEFINITION.to_s
489
- Killbill::Plugin::Model::ObjectType.new(:TAG_DEFINITION)
490
- elsif type.to_s == Java::com.ning.billing.ObjectType::TENANT.to_s
491
- Killbill::Plugin::Model::ObjectType.new(:TENANT)
492
- else
493
- Killbill::Plugin::Model::ObjectType.new(:TENANT_KVS)
494
- end
495
- end
496
-
497
- def from_bus_event_type(type)
498
-
499
- if type.to_s == Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::ACCOUNT_CREATION.to_s
500
- Killbill::Plugin::Model::ExtBusEventType.new(:ACCOUNT_CREATION)
501
- elsif type.to_s == Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::ACCOUNT_CHANGE.to_s
502
- Killbill::Plugin::Model::ExtBusEventType.new(:ACCOUNT_CHANGE)
503
- elsif type.to_s == Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::SUBSCRIPTION_CREATION.to_s
504
- Killbill::Plugin::Model::ExtBusEventType.new(:SUBSCRIPTION_CREATION)
505
- elsif type.to_s == Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::SUBSCRIPTION_PHASE.to_s
506
- Killbill::Plugin::Model::ExtBusEventType.new(:SUBSCRIPTION_PHASE)
507
- elsif type.to_s == Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::SUBSCRIPTION_CHANGE.to_s
508
- Killbill::Plugin::Model::ExtBusEventType.new(:SUBSCRIPTION_CHANGE)
509
- elsif type.to_s == Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::SUBSCRIPTION_CANCEL.to_s
510
- Killbill::Plugin::Model::ExtBusEventType.new(:SUBSCRIPTION_CANCEL)
511
- elsif type.to_s == Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::SUBSCRIPTION_UNCANCEL.to_s
512
- Killbill::Plugin::Model::ExtBusEventType.new(:SUBSCRIPTION_UNCANCEL)
513
- elsif type.to_s == Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::OVERDUE_CHANGE.to_s
514
- Killbill::Plugin::Model::ExtBusEventType.new(:OVERDUE_CHANGE)
515
- elsif type.to_s == Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::INVOICE_CREATION.to_s
516
- Killbill::Plugin::Model::ExtBusEventType.new(:INVOICE_CREATION)
517
- elsif type.to_s == Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::INVOICE_ADJUSTMENT.to_s
518
- Killbill::Plugin::Model::ExtBusEventType.new(:INVOICE_ADJUSTMENT)
519
- elsif type.to_s == Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::PAYMENT_SUCCESS.to_s
520
- Killbill::Plugin::Model::ExtBusEventType.new(:PAYMENT_SUCCESS)
521
- elsif type.to_s == Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::PAYMENT_FAILED.to_s
522
- Killbill::Plugin::Model::ExtBusEventType.new(:PAYMENT_FAILED)
523
- elsif type.to_s == Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::TAG_CREATION.to_s
524
- Killbill::Plugin::Model::ExtBusEventType.new(:TAG_CREATION)
525
- elsif type.to_s == Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::TAG_DELETION.to_s
526
- Killbill::Plugin::Model::ExtBusEventType.new(:TAG_DELETION)
527
- elsif type.to_s == Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::CUSTOM_FIELD_CREATION.to_s
528
- Killbill::Plugin::Model::ExtBusEventType.new(:CUSTOM_FIELD_CREATION)
529
- else
530
- Killbill::Plugin::Model::ExtBusEventType.new(:CUSTOM_FIELD_DELETION)
531
- end
532
- end
533
-
534
- end
535
- end
536
- end
537
- end