killbill-client 0.5.4 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1e0db1e2e526ed9e16ee35f1c47831dad9c7bd2a
4
+ data.tar.gz: 69bb1815ea15b3055edfa0ab6909ff1adcf2bdd4
5
+ SHA512:
6
+ metadata.gz: 59957a26919c8c96eaf24dbe9578d056e33422eab28ea87b83ebfdf0df677b1d94dceb03961eb8cba9bad00af03705ee5bc20a28ad340f2806b3607282cf035a
7
+ data.tar.gz: e02d2802fb9c83bcb769abe14c4a4b47d03af061fd897035fcf175e629322352c3657679dd3cf9bef45b256465765c5fcd54573082cb501b04b7875bb25bc07c
@@ -4,6 +4,13 @@ module KillBillClient
4
4
 
5
5
  has_many :audit_logs, KillBillClient::Model::AuditLog
6
6
 
7
+ AUTO_PAY_OFF_ID = '00000000-0000-0000-0000-000000000001'
8
+ AUTO_INVOICING_ID = '00000000-0000-0000-0000-000000000002'
9
+ OVERDUE_ENFORCEMENT_OFF_ID = '00000000-0000-0000-0000-000000000003'
10
+ WRITTEN_OFF_ID = '00000000-0000-0000-0000-000000000004'
11
+ MANUAL_PAY_ID = '00000000-0000-0000-0000-000000000005'
12
+ TEST_ID = '00000000-0000-0000-0000-000000000006'
13
+
7
14
  KILLBILL_API_ACCOUNTS_PREFIX = "#{KILLBILL_API_PREFIX}/accounts"
8
15
 
9
16
  class << self
@@ -91,7 +98,7 @@ module KillBillClient
91
98
  end
92
99
 
93
100
  def add_tag(tag_name, user = nil, reason = nil, comment = nil, options = {})
94
- tag_definition = TagDefinition.find_by_name(tag_name)
101
+ tag_definition = TagDefinition.find_by_name(tag_name, options)
95
102
  if tag_definition.nil?
96
103
  tag_definition = TagDefinition.new
97
104
  tag_definition.name = tag_name
@@ -99,18 +106,7 @@ module KillBillClient
99
106
  tag_definition = TagDefinition.create(user, options)
100
107
  end
101
108
 
102
- created_tag = self.class.post "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/tags",
103
- {},
104
- {
105
- :tagList => tag_definition.id
106
- },
107
- {
108
- :user => user,
109
- :reason => reason,
110
- :comment => comment,
111
- }.merge(options),
112
- Tag
113
- created_tag.refresh(options)
109
+ add_tag_from_definition_id(tag_definition.id, user, reason, comment, options)
114
110
  end
115
111
 
116
112
  def remove_tag(tag_name, user = nil, reason = nil, comment = nil, options = {})
@@ -127,6 +123,81 @@ module KillBillClient
127
123
  :comment => comment,
128
124
  }.merge(options)
129
125
  end
126
+
127
+
128
+ def auto_pay_off?(options)
129
+ control_tag_off?(AUTO_PAY_OFF_ID, options)
130
+ end
131
+
132
+ def set_auto_pay_off(user = nil, reason = nil, comment = nil, options)
133
+ add_tag_from_definition_id(AUTO_PAY_OFF_ID, user, reason, comment, options)
134
+ end
135
+
136
+ def auto_invoicing?(options)
137
+ control_tag_off?(AUTO_INVOICING_ID, options)
138
+ end
139
+
140
+ def set_auto_invoicing(user = nil, reason = nil, comment = nil, options)
141
+ add_tag_from_definition_id(AUTO_INVOICING_ID, user, reason, comment, options)
142
+ end
143
+
144
+ def overdue_enforcement_off?(options)
145
+ control_tag_off?(OVERDUE_ENFORCEMENT_OFF_ID, options)
146
+ end
147
+
148
+ def set_overdue_enforcement_off(user = nil, reason = nil, comment = nil, options)
149
+ add_tag_from_definition_id(OVERDUE_ENFORCEMENT_OFF_ID, user, reason, comment, options)
150
+ end
151
+
152
+ def written_off?(options)
153
+ control_tag_off?(WRITTEN_OFF_ID, options)
154
+ end
155
+
156
+ def set_written_off( user = nil, reason = nil, comment = nil, options)
157
+ add_tag_from_definition_id(WRITTEN_OFF_ID, user, reason, comment, options)
158
+ end
159
+
160
+ def manual_pay?(options)
161
+ control_tag_off?(MANUAL_PAY_ID, options)
162
+ end
163
+
164
+ def set_manual_pay(user = nil, reason = nil, comment = nil, options)
165
+ add_tag_from_definition_id(MANUAL_PAY_ID, user, reason, comment, options)
166
+ end
167
+
168
+
169
+ def test?(options)
170
+ control_tag_off?(TEST_ID, options)
171
+ end
172
+
173
+ def set_test(user = nil, reason = nil, comment = nil, options)
174
+ add_tag_from_definition_id(TEST_ID, user, reason, comment, options)
175
+ end
176
+
177
+ private
178
+
179
+ def control_tag_off?(control_tag_definition_id, options)
180
+ res = tags('NONE', options)
181
+ !((res || []).select do |t|
182
+ t.tag_definition_id == control_tag_definition_id
183
+ end.first.nil?)
184
+ end
185
+
186
+ def add_tag_from_definition_id(tag_definition_id, user = nil, reason = nil, comment = nil, options = {})
187
+ created_tag = self.class.post "#{KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/tags",
188
+ {},
189
+ {
190
+ :tagList => tag_definition_id
191
+ },
192
+ {
193
+ :user => user,
194
+ :reason => reason,
195
+ :comment => comment,
196
+ }.merge(options),
197
+ Tag
198
+ created_tag.refresh(options)
199
+ end
200
+
130
201
  end
131
202
  end
132
203
  end
@@ -32,10 +32,11 @@ module KillBillClient
32
32
 
33
33
 
34
34
  # Transfer the bundle to the new account. the new account_id should be set in this object
35
- def transfer(bundle_id, requested_date = nil, user = nil, reason = nil, comment = nil, options = {})
35
+ def transfer(bundle_id, requested_date = nil, billing_policy = nil, user = nil, reason = nil, comment = nil, options = {})
36
36
 
37
37
  params = {}
38
38
  params[:requestedDate] = requested_date unless requested_date.nil?
39
+ params[:billingPolicy] = billing_policy unless billing_policy.nil?
39
40
  result = self.class.put "#{KILLBILL_API_BUNDLES_PREFIX}/#{bundle_id}",
40
41
  to_json,
41
42
  params,
@@ -13,11 +13,35 @@ module KillBillClient
13
13
  def find_by_id_or_number(id_or_number, with_items = true, audit = "NONE", options = {})
14
14
  get "#{KILLBILL_API_INVOICES_PREFIX}/#{id_or_number}",
15
15
  {
16
- :withItems => with_items,
17
- :audit => audit
16
+ :withItems => with_items,
17
+ :audit => audit
18
18
  },
19
19
  options
20
20
  end
21
+
22
+ def trigger_invoice(account_id, target_date, dry_run, user = nil, reason = nil, comment = nil, options = {})
23
+ query_map = {:accountId => account_id}
24
+ query_map[:targetDate] = target_date if !target_date.nil?
25
+ query_map[:dryRun] = dry_run if !dry_run.nil?
26
+
27
+ begin
28
+ res = post "#{KILLBILL_API_INVOICES_PREFIX}",
29
+ {},
30
+ query_map,
31
+ {
32
+ :user => user,
33
+ :reason => reason,
34
+ :comment => comment,
35
+ }.merge(options),
36
+ Invoice
37
+
38
+ res.refresh(options)
39
+
40
+ rescue KillBillClient::API::BadRequest => e
41
+ # No invoice to generate : TODO parse json to verify this is indeed the case
42
+ end
43
+ end
44
+
21
45
  end
22
46
  end
23
47
  end
@@ -5,9 +5,10 @@ module KillBillClient
5
5
  has_many :audit_logs, KillBillClient::Model::AuditLog
6
6
 
7
7
  class << self
8
- def find_all_by_account_id account_id, audit = "NONE", options = {}
8
+ def find_all_by_account_id account_id, included_deleted = false, audit = "NONE", options = {}
9
9
  get "#{Account::KILLBILL_API_ACCOUNTS_PREFIX}/#{account_id}/tags",
10
10
  {
11
+ :includedDeleted => included_deleted,
11
12
  :audit => audit
12
13
  },
13
14
  options
@@ -2,7 +2,7 @@ module KillBillClient
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 5
5
- PATCH = 4
5
+ PATCH = 5
6
6
  PRE = nil
7
7
 
8
8
  VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
metadata CHANGED
@@ -1,64 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-client
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.5.4
4
+ version: 0.5.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Killbill core team
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-12-06 00:00:00.000000000 Z
11
+ date: 2014-01-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: json
16
- version_requirements: !ruby/object:Gem::Requirement
15
+ requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
17
  - - "~>"
19
18
  - !ruby/object:Gem::Version
20
19
  version: 1.8.0
21
- none: false
22
- requirement: !ruby/object:Gem::Requirement
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.8.0
27
- none: false
28
- prerelease: false
29
- type: :runtime
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
- version_requirements: !ruby/object:Gem::Requirement
29
+ requirement: !ruby/object:Gem::Requirement
33
30
  requirements:
34
31
  - - ">="
35
32
  - !ruby/object:Gem::Version
36
33
  version: 10.0.0
37
- none: false
38
- requirement: !ruby/object:Gem::Requirement
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
39
37
  requirements:
40
38
  - - ">="
41
39
  - !ruby/object:Gem::Version
42
40
  version: 10.0.0
43
- none: false
44
- prerelease: false
45
- type: :development
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
- version_requirements: !ruby/object:Gem::Requirement
43
+ requirement: !ruby/object:Gem::Requirement
49
44
  requirements:
50
45
  - - "~>"
51
46
  - !ruby/object:Gem::Version
52
47
  version: 2.12.0
53
- none: false
54
- requirement: !ruby/object:Gem::Requirement
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
55
51
  requirements:
56
52
  - - "~>"
57
53
  - !ruby/object:Gem::Version
58
54
  version: 2.12.0
59
- none: false
60
- prerelease: false
61
- type: :development
62
55
  description: An API client library for Kill Bill.
63
56
  email: killbilling-users@googlegroups.com
64
57
  executables: []
@@ -144,7 +137,8 @@ files:
144
137
  homepage: http://www.killbilling.org
145
138
  licenses:
146
139
  - Apache License (2.0)
147
- post_install_message:
140
+ metadata: {}
141
+ post_install_message:
148
142
  rdoc_options:
149
143
  - "--exclude"
150
144
  - "."
@@ -155,22 +149,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
149
  - - ">="
156
150
  - !ruby/object:Gem::Version
157
151
  version: 1.8.6
158
- none: false
159
152
  required_rubygems_version: !ruby/object:Gem::Requirement
160
153
  requirements:
161
154
  - - ">="
162
155
  - !ruby/object:Gem::Version
163
- segments:
164
- - 0
165
- hash: 2
166
- version: !binary |-
167
- MA==
168
- none: false
156
+ version: '0'
169
157
  requirements: []
170
- rubyforge_project:
171
- rubygems_version: 1.8.24
172
- signing_key:
173
- specification_version: 3
158
+ rubyforge_project:
159
+ rubygems_version: 2.2.0
160
+ signing_key:
161
+ specification_version: 4
174
162
  summary: Kill Bill client library.
175
163
  test_files:
176
164
  - spec/killbill_client/model_relation_spec.rb