magnetik 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46632b916b07bdeb2940beecad6f7df36800989e
4
- data.tar.gz: 4ad872c709af5335152464779d4ba7f5a73eb2b3
3
+ metadata.gz: 1d2a41951a797368d04c1fc74b1d21d99a7758fb
4
+ data.tar.gz: 774b86a2abd008380b4b830856b3dd4dbf5f4e55
5
5
  SHA512:
6
- metadata.gz: 3bf9c9f3ce8e0bc1bf9c63cce519eda6fdd74eb660155cd7cb9cfe558f4db65486eded26ff15d209738503440aef4c4316f94795a3b9e14878effd20bcd3a93b
7
- data.tar.gz: 01ccbe73e68064bf171389c2551a97451379248a7fe661c5c4d400d37b137f750194acb9067b17f102c00b806fef0c34539facc4b8c342851dfe87517177157a
6
+ metadata.gz: d2a3ec948e1b15807794eba7bbf27b8bf692a1a713159b125bc625cd062a80c927fd32705208ddbe6ed075dc31520c0843a9387034743025ded54128c0c54fd9
7
+ data.tar.gz: 42f6f4b8df3bfd19b3f6497e8baf294cd361dd1f8920721998bb328dce42b60820058d436fc4ea3026e8dd9171be7d6601fb6a0e24d1da250b3e490e6b245992
@@ -12,7 +12,7 @@ module Magnetik
12
12
 
13
13
  def create
14
14
  @token = create_params[:token]
15
- @use_case = CreateCreditCard.perform(user, @token)
15
+ @use_case = CreateCreditCard.perform(customer, @token)
16
16
 
17
17
  if @use_case.success?
18
18
  render json: { credit_card: @use_case.local_card }, status: :ok
@@ -53,6 +53,10 @@ module Magnetik
53
53
  @user ||= method(Magnetik.current_user_method).call
54
54
  end
55
55
 
56
+ def customer
57
+ @customer ||= user
58
+ end
59
+
56
60
  def collection
57
61
  @credit_cards ||= user.credit_cards.limit(30)
58
62
  end
@@ -4,14 +4,14 @@ module Magnetik
4
4
 
5
5
  attr_reader :local_card
6
6
 
7
- def initialize(user, token)
8
- @token = token
9
- @user = user
7
+ def initialize(actor, token)
8
+ @token = token
9
+ @actor = actor
10
10
  @remote_customer = nil
11
11
  end
12
12
 
13
13
  def perform
14
- if @user.has_customer?
14
+ if @actor.has_stripe_customer?
15
15
  fetch_customer
16
16
  else
17
17
  create_remote_customer
@@ -28,7 +28,7 @@ module Magnetik
28
28
  attr_reader :remote_customer, :remote_card
29
29
 
30
30
  def fetch_customer
31
- @remote_customer = Stripe::Customer.retrieve(@user.stripe_customer_id)
31
+ @remote_customer = Stripe::Customer.retrieve(@actor.stripe_customer_id)
32
32
  end
33
33
 
34
34
  def create_remote_customer
@@ -38,7 +38,7 @@ module Magnetik
38
38
  end
39
39
 
40
40
  def create_local_customer
41
- @user.update_attributes(stripe_customer_id: remote_customer.id).tap do |success|
41
+ @actor.update_attributes(stripe_customer_id: remote_customer.id).tap do |success|
42
42
  errors.add(:base, "User failed to save") unless success
43
43
  end
44
44
  end
@@ -52,7 +52,7 @@ module Magnetik
52
52
 
53
53
  def create_local_card
54
54
  @local_card = CreditCard.new({
55
- customer: @user,
55
+ customer: @actor,
56
56
  stripe_card_id: remote_card[:id],
57
57
  last_4_digits: remote_card[:last4],
58
58
  exp_month: remote_card[:exp_month],
@@ -14,7 +14,7 @@ module Magnetik
14
14
  end
15
15
 
16
16
  module LocalInstanceMethods
17
- def has_customer?
17
+ def has_stripe_customer?
18
18
  stripe_customer_id.present?
19
19
  end
20
20
  end
@@ -1,3 +1,3 @@
1
1
  module Magnetik
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magnetik
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Ivanopoulos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-03 00:00:00.000000000 Z
11
+ date: 2015-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails