kaui 0.0.5 → 0.0.6

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.
@@ -19,12 +19,7 @@ class Kaui::AccountsController < Kaui::EngineController
19
19
  end
20
20
 
21
21
  if @account.present?
22
- # TODO: add when payment methods are implemented
23
- # @payment_methods = Kaui::KillbillHelper.get_payment_methods(@account_id)
24
- # unless @payment_methods.is_a?(Array)
25
- # flash[:error] = "No payment methods for account #{@account_id}"
26
- # redirect_to :action => :index
27
- # end
22
+ @payment_methods = Kaui::KillbillHelper.get_payment_methods(@account_id)
28
23
  else
29
24
  flash[:error] = "Account #{@account_id} not found"
30
25
  redirect_to :action => :index
@@ -49,16 +44,15 @@ class Kaui::AccountsController < Kaui::EngineController
49
44
  end
50
45
 
51
46
  def set_default_payment_method
52
- @external_key = params[:id]
47
+ @account_id = params[:id]
53
48
  # TODO
54
49
  redirect_to :back
55
50
  end
56
51
 
57
52
  def delete_payment_method
58
- @external_key = params[:id]
59
53
  @payment_method_id = params[:payment_method_id]
60
- if @external_key.present? && @payment_method_id.present?
61
- Kaui::KillbillHelper::delete_payment_method(@external_key, @payment_method_id)
54
+ if @payment_method_id.present?
55
+ Kaui::KillbillHelper::delete_payment_method(@payment_method_id)
62
56
  else
63
57
  flash[:notice] = "No id given"
64
58
  end
@@ -2,8 +2,8 @@ module Kaui
2
2
  module DateHelper
3
3
  def format_date(date)
4
4
  # TODO: make timezone configurable
5
- parsed_date = DateTime.parse(date).in_time_zone("Pacific Time (US & Canada)")
6
- parsed_date.to_s(:pretty) + "&nbsp;" + (parsed_date.dst? ? "PDT" : "PST")
5
+ parsed_date = DateTime.parse(date).in_time_zone(ActiveSupport::TimeZone::ZONES_MAP["Pacific Time (US & Canada)"])
6
+ parsed_date.to_s(:date_only)
7
7
  end
8
8
  end
9
9
  end
@@ -297,7 +297,7 @@ module Kaui
297
297
  def self.delete_payment_method(account_id, payment_method_id, current_user = nil, reason = nil, comment = nil)
298
298
  begin
299
299
  call_killbill :delete,
300
- "/1.0/accounts/#{account_id}/paymentMethods/#{payment_method_id}",
300
+ "/1.0/kb/accounts/#{account_id}/paymentMethods/#{payment_method_id}",
301
301
  "X-Killbill-CreatedBy" => current_user,
302
302
  "X-Killbill-Reason" => "#{reason}",
303
303
  "X-Killbill-Comment" => "#{comment}"
@@ -308,7 +308,7 @@ module Kaui
308
308
 
309
309
  def self.get_payment_methods(account_id)
310
310
  begin
311
- data = call_killbill :get, "/1.0/accounts/#{account_id}/paymentMethods"
311
+ data = call_killbill :get, "/1.0/kb/accounts/#{account_id}/paymentMethods?withPluginInfo=true"
312
312
  process_response(data, :multiple) {|json| Kaui::PaymentMethod.new(json) }
313
313
  rescue => e
314
314
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
@@ -0,0 +1,45 @@
1
+ require 'active_model'
2
+
3
+ class Kaui::PaymentMethod < Kaui::Base
4
+ define_attr :account_id
5
+ define_attr :is_default
6
+ define_attr :payment_method_id
7
+ define_attr :plugin_name
8
+ has_one :plugin_info, Kaui::PluginInfo
9
+
10
+ def initialize(data = {})
11
+ super(:account_id => data['accountId'],
12
+ :is_default => data['isDefault'],
13
+ :payment_method_id => data['paymentMethodId'],
14
+ :plugin_name => data['pluginName'],
15
+ :plugin_info => data['pluginInfo'])
16
+ end
17
+
18
+ def card_type
19
+ plugin_info.property("cardType") if plugin_info.present?
20
+ end
21
+
22
+ def type
23
+ plugin_info.property("type") if plugin_info.present?
24
+ end
25
+
26
+ def mask_number
27
+ plugin_info.property("maskNumber") if plugin_info.present?
28
+ end
29
+
30
+ def card_holder_name
31
+ plugin_info.property("cardHolderName") if plugin_info.present?
32
+ end
33
+
34
+ def expiration_dt
35
+ plugin_info.property("expirationDate") if plugin_info.present?
36
+ end
37
+
38
+ def baid
39
+ plugin_info.property("baid") if plugin_info.present?
40
+ end
41
+
42
+ def email
43
+ plugin_info.property("email") if plugin_info.present?
44
+ end
45
+ end
@@ -0,0 +1,16 @@
1
+ require 'active_model'
2
+
3
+ class Kaui::PluginInfo < Kaui::Base
4
+ define_attr :external_payment_id
5
+ has_many :properties, Kaui::PluginInfoProperty
6
+
7
+ def initialize(data = {})
8
+ super(:external_payment_id => data['externalPaymentId'],
9
+ :properties => data['properties'])
10
+ end
11
+
12
+ def property(key)
13
+ prop = properties.find { |prop| prop.key == key } unless properties.nil?
14
+ prop.value unless prop.nil?
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ require 'active_model'
2
+
3
+ class Kaui::PluginInfoProperty < Kaui::Base
4
+ define_attr :key
5
+ define_attr :value
6
+ define_attr :is_updatable
7
+
8
+ def initialize(data = {})
9
+ super(:key => data['key'],
10
+ :value => data['value'],
11
+ :is_updatable => data['isUpdatable'])
12
+ end
13
+ end
@@ -17,7 +17,7 @@
17
17
  <th class="sort-title-string">Requested Date</th>
18
18
  <th class="data-table-sort-desc sort-title-string">Effective Date</th>
19
19
  <th>Bundle Name</th>
20
- <th>Event Type</th>
20
+ <th class="data-table-sort-desc">Event Type</th>
21
21
  <th>Details</th>
22
22
  <th>Reason Code / Comments</th>
23
23
  <th>Actions</th>
@@ -29,10 +29,12 @@
29
29
  <%= render :partial => "kaui/tags/tags_table",
30
30
  :locals => { :tags => @tags, :tags_url_or_path => kaui_engine.edit_account_tags_path(:params => { :account_id => @account.account_id }) } %>
31
31
  </dl>
32
+ <% if @subscriptions.present? %>
33
+ <%= render :partial => "kaui/subscriptions/subscriptions_table", :locals => { :subscriptions => @subscriptions } %>
34
+ <% end %>
32
35
  <% if @payment_methods.present? %>
33
- <%= render :partial => "kaui/subscriptions/subscriptions_table" %>
36
+ <%= render :partial => "kaui/payment_methods/payment_methods_table", :locals => { :payment_methods => @payment_methods } %>
34
37
  <% end %>
35
-
36
38
  <% else %>
37
39
  <p>Account not found</p>
38
40
  <% end %>
@@ -6,7 +6,7 @@
6
6
  <dt>Bundle key:</dt>
7
7
  <dd><%= @bundle.external_key %>&nbsp;</dd>
8
8
  <% if @subscriptions.present? %>
9
- <%= render :partial => "kaui/subscriptions/subscriptions_table" %>
9
+ <%= render :partial => "kaui/subscriptions/subscriptions_table", :locals => { :subscriptions => @subscriptions } %>
10
10
  <% end %>
11
11
  <% else %>
12
12
  <p>Bundle not found</p>
@@ -4,31 +4,30 @@
4
4
  <table class="table table-condensed table-striped">
5
5
  <thead>
6
6
  <tr>
7
+ <th>Type</th>
7
8
  <th>Card Type</th>
9
+ <th>Account Name</th>
8
10
  <th>Mask Number / Baid</th>
9
11
  <th>Expiration Date</th>
10
12
  <th>Default Method</th>
11
13
  <th>Actions</th>
12
- </tr>
14
+ </tr>
13
15
  </thead>
14
16
  <tbody>
15
- <% if @payment_methods.present? %>
16
- <% @payment_methods.each do |payment_method| %>
17
+ <% if payment_methods.present? && !payment_methods.nil? %>
18
+ <% payment_methods.each do |payment_method| %>
17
19
  <tr>
18
- <td><%= payment_method["cardType"] %></a></td>
19
- <td><%= payment_method["maskNumber"] %></td>
20
- <td><%= payment_method["expirationDate"] %></td>
20
+ <td><%= payment_method.type %></a></td>
21
+ <td><%= payment_method.card_type %></a></td>
22
+ <td><%= payment_method.card_holder_name %><%= payment_method.email %></a></td>
23
+ <td><%= payment_method.mask_number %><%= payment_method.baid %></td>
24
+ <td><%= payment_method.expiration_dt %></td>
21
25
  <td>
22
- <% if payment_method['defaultMethod'] %>
26
+ <% if payment_method.is_default %>
23
27
  <i class="icon-ok"></i>
24
- <% else %>
25
- <%= link_to "Make Default", kaui_engine.set_default_payment_method_account_path(:id => @account_id, :params => { :payment_method_id => payment_method['id'] }), :method => "PUT", :confirm => "Are you sure ?", :class => "btn btn-mini" %>
26
28
  <% end %>
27
- </td>
29
+ </td>
28
30
  <td>
29
- <% unless payment_method['defaultMethod'] %>
30
- <%= link_to "Delete", kaui_engine.delete_payment_method_account_path(:id => @account_id, :params => { :payment_method_id => payment_method['id'] }), :method => "DELETE", :confirm => "Are you sure ?", :class => "btn btn-mini" %>
31
- <% end %>
32
31
  </td>
33
32
  </tr>
34
33
  <% end %>
@@ -14,8 +14,8 @@
14
14
  </tr>
15
15
  </thead>
16
16
  <tbody>
17
- <% if @subscriptions.present? && !@subscriptions.nil? %>
18
- <% @subscriptions.each do |sub| %>
17
+ <% if subscriptions.present? && !subscriptions.nil? %>
18
+ <% subscriptions.each do |sub| %>
19
19
  <tr>
20
20
  <td><%= sub.product_category.downcase.capitalize if sub.product_category.present? %></td>
21
21
  <td><%= sub.product_name.downcase.capitalize if sub.product_name.present? %></td>
@@ -1,2 +1,4 @@
1
1
  Time::DATE_FORMATS[:pretty] = "%b %d %Y at %H:%M"
2
- Date::DATE_FORMATS[:pretty] = "%b %d %Y at %H:%M"
2
+ Date::DATE_FORMATS[:pretty] = "%b %d %Y at %H:%M"
3
+ Time::DATE_FORMATS[:date_only] = "%Y-%m-%d"
4
+ Date::DATE_FORMATS[:date_only] = "%Y-%m-%d"
data/lib/kaui/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kaui
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaui
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alena Dudzinskaya
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-24 00:00:00 Z
18
+ date: 2012-07-26 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Rails UI plugin for Killbill administration.
@@ -76,6 +76,9 @@ files:
76
76
  - app/models/kaui/invoice_item.rb
77
77
  - app/models/kaui/payment.rb
78
78
  - app/models/kaui/payment_attempt.rb
79
+ - app/models/kaui/payment_method.rb
80
+ - app/models/kaui/plugin_info.rb
81
+ - app/models/kaui/plugin_info_property.rb
79
82
  - app/models/kaui/product.rb
80
83
  - app/models/kaui/refund.rb
81
84
  - app/models/kaui/subscription.rb