forest_liana 1.0.7 → 1.0.8

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: 325ef83e8bd03a96c828e05dc6e640d8f5673640
4
- data.tar.gz: 99ab4692f6a7b6cc88168885116c6175a28eb181
3
+ metadata.gz: a97913520a95aedb4cb945b87ffe30f3d36749fe
4
+ data.tar.gz: 40f46b92dc07352eb45f224a5a45bf3e06e2980a
5
5
  SHA512:
6
- metadata.gz: 3ca9b4a5cbf975413fb64c367790e381903822f10e79a6f0aaa0cd3e36dfb8bcb0c33512e04fb5c4261267780f616c7c769696f57e7c5fa32bb55cd7324c955f
7
- data.tar.gz: ee676ba235571c1e6b78fd5e68aee477da39ee3ccd618b2bb373e9a37899c4056354e8926d73958c64c2b52e3dce4e7e663b02026b946138c826f775ed0fede2
6
+ metadata.gz: 67bb87afe2d47d6ee407506c5f64a64d1291ce7d4a251d358d8fb29a305a082f4c993500ef14a8e62719f9004a7d262c47533c9f39f4907fa8bccdd13f0a3ac3
7
+ data.tar.gz: 0c4ec0a92d1635e2142ef2c9329d57b4655eee8a582fbce261c13e64c87e346411234ceecd7d42de90ce64f18e7d4dc83fb1cdb5f0026053a06577da7823ee05
@@ -12,7 +12,5 @@ module ForestLiana
12
12
 
13
13
  render json: serialize_models(result, serializer: ApimapSerializer)
14
14
  end
15
-
16
-
17
15
  end
18
16
  end
@@ -18,6 +18,11 @@ module ForestLiana
18
18
  json[:meta][:count] = options[:count]
19
19
  end
20
20
 
21
+ if !options[:has_more].nil?
22
+ json[:meta] = {} unless json[:meta]
23
+ json[:meta][:has_more] = options[:has_more]
24
+ end
25
+
21
26
  json
22
27
  end
23
28
 
@@ -0,0 +1,52 @@
1
+ module ForestLiana
2
+ class StripeController < ForestLiana::ApplicationController
3
+
4
+ def payments
5
+ getter = StripePaymentsGetter.new(params,
6
+ request.headers['Stripe-Secret-Key'],
7
+ request.headers['Stripe-Reference'])
8
+ getter.perform
9
+
10
+ render json: serialize_models(getter.records, {
11
+ count: getter.count,
12
+ include: ['customer']
13
+ })
14
+ end
15
+
16
+ def refund
17
+ begin
18
+ refunder = StripePaymentRefunder.new(params)
19
+ refunder.perform
20
+
21
+ render json: {}
22
+ rescue Stripe::InvalidRequestError => err
23
+ render json: { error: err.message }, status: 400
24
+ end
25
+ end
26
+
27
+ def cards
28
+ getter = StripeCardsGetter.new(params,
29
+ request.headers['Stripe-Secret-Key'],
30
+ request.headers['Stripe-Reference'])
31
+ getter.perform
32
+
33
+ render json: serialize_models(getter.records, {
34
+ count: getter.count,
35
+ include: ['customer']
36
+ })
37
+ end
38
+
39
+ def invoices
40
+ getter = StripeInvoicesGetter.new(params,
41
+ request.headers['Stripe-Secret-Key'],
42
+ request.headers['Stripe-Reference'])
43
+ getter.perform
44
+
45
+ render json: serialize_models(getter.records, {
46
+ count: getter.count,
47
+ include: ['customer']
48
+ })
49
+ end
50
+
51
+ end
52
+ end
@@ -14,13 +14,21 @@ module ForestLiana
14
14
  end
15
15
 
16
16
  def self.get_serializer_name(active_record_class)
17
- class_name = active_record_class.table_name.classify
18
- module_name = class_name.deconstantize
19
-
20
- name = module_name if module_name
21
- name += class_name.demodulize
22
-
23
- "ForestLiana::#{name}Serializer"
17
+ if active_record_class == Stripe::Charge
18
+ "ForestLiana::StripePaymentSerializer"
19
+ elsif active_record_class == Stripe::Card
20
+ "ForestLiana::StripeCardSerializer"
21
+ elsif active_record_class == Stripe::Invoice
22
+ "ForestLiana::StripeInvoiceSerializer"
23
+ else
24
+ class_name = active_record_class.table_name.classify
25
+ module_name = class_name.deconstantize
26
+
27
+ name = module_name if module_name
28
+ name += class_name.demodulize
29
+
30
+ "ForestLiana::#{name}Serializer"
31
+ end
24
32
  end
25
33
 
26
34
  def serializer_for(active_record_class)
@@ -0,0 +1,46 @@
1
+ module ForestLiana
2
+ class StripeCardSerializer
3
+ include JSONAPI::Serializer
4
+
5
+ attribute :last4
6
+ attribute :brand
7
+ attribute :funding
8
+ attribute :exp_month
9
+ attribute :exp_year
10
+ attribute :country
11
+ attribute :name
12
+ attribute :address_line1
13
+ attribute :address_line2
14
+ attribute :address_city
15
+ attribute :address_state
16
+ attribute :address_zip
17
+ attribute :address_country
18
+ attribute :cvc_check
19
+
20
+ has_one :customer
21
+
22
+ def self_link
23
+ "/forest#{super}"
24
+ end
25
+
26
+ def type
27
+ 'stripe-cards'
28
+ end
29
+
30
+ def format_name(attribute_name)
31
+ attribute_name.to_s
32
+ end
33
+
34
+ def unformat_name(attribute_name)
35
+ attribute_name.to_s.underscore
36
+ end
37
+
38
+ def relationship_self_link(attribute_name)
39
+ nil
40
+ end
41
+
42
+ def relationship_related_link(attribute_name)
43
+ nil
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,47 @@
1
+ module ForestLiana
2
+ class StripeInvoiceSerializer
3
+ include JSONAPI::Serializer
4
+
5
+ attribute :amount_due
6
+ attribute :attempt_count
7
+ attribute :attempted
8
+ attribute :closed
9
+ attribute :currency
10
+ attribute :date
11
+ attribute :forgiven
12
+ attribute :paid
13
+ attribute :period_end
14
+ attribute :period_start
15
+ attribute :subtotal
16
+ attribute :total
17
+ attribute :application_fee
18
+ attribute :tax
19
+ attribute :tax_percent
20
+
21
+ has_one :customer
22
+
23
+ def self_link
24
+ "/forest#{super}"
25
+ end
26
+
27
+ def type
28
+ 'stripe-invoices'
29
+ end
30
+
31
+ def format_name(attribute_name)
32
+ attribute_name.to_s
33
+ end
34
+
35
+ def unformat_name(attribute_name)
36
+ attribute_name.to_s.underscore
37
+ end
38
+
39
+ def relationship_self_link(attribute_name)
40
+ nil
41
+ end
42
+
43
+ def relationship_related_link(attribute_name)
44
+ nil
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,38 @@
1
+ module ForestLiana
2
+ class StripePaymentSerializer
3
+ include JSONAPI::Serializer
4
+
5
+ attribute :description
6
+ attribute :refunded
7
+ attribute :currency
8
+ attribute :status
9
+ attribute :amount
10
+ attribute :created
11
+
12
+ has_one :customer
13
+
14
+ def self_link
15
+ "/forest#{super}"
16
+ end
17
+
18
+ def type
19
+ 'stripe-payments'
20
+ end
21
+
22
+ def format_name(attribute_name)
23
+ attribute_name.to_s
24
+ end
25
+
26
+ def unformat_name(attribute_name)
27
+ attribute_name.to_s.underscore
28
+ end
29
+
30
+ def relationship_self_link(attribute_name)
31
+ nil
32
+ end
33
+
34
+ def relationship_related_link(attribute_name)
35
+ nil
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,73 @@
1
+ module ForestLiana
2
+ class StripeCardsGetter
3
+ attr_accessor :records
4
+
5
+ def initialize(params, secret_key, reference)
6
+ @params = params
7
+ @reference_model, @reference_field = reference_model(reference)
8
+ Stripe.api_key = secret_key
9
+ end
10
+
11
+ def count
12
+ @cards.try(:total_count) || 0
13
+ end
14
+
15
+ def perform
16
+ params = { limit: limit, offset: offset, object: 'card' }
17
+ params['include[]'] = 'total_count'
18
+
19
+ resource = @reference_model.find(reference_model_id)
20
+ customer = resource[@reference_field]
21
+
22
+ fetch_cards(customer, params)
23
+ end
24
+
25
+ def fetch_cards(customer, params)
26
+ @cards = Stripe::Customer.retrieve(customer).sources.all(params)
27
+
28
+ @records = @cards.data.map do |d|
29
+ query = {}
30
+ query[@reference_field] = d.customer
31
+ d.customer = @reference_model.find_by(query)
32
+
33
+ d
34
+ end
35
+ end
36
+
37
+ def reference_model(reference)
38
+ resource_name, reference_field = reference.split('.')
39
+ reference_model = SchemaUtils.find_model_from_table_name(resource_name)
40
+
41
+ [reference_model, reference_field]
42
+ end
43
+
44
+ def reference_model_id
45
+ @params["#{@reference_model.table_name.singularize()}Id"]
46
+ end
47
+
48
+ def offset
49
+ return 0 unless pagination?
50
+
51
+ number = @params[:page][:number]
52
+ if number && number.to_i > 0
53
+ (number.to_i - 1) * limit
54
+ else
55
+ 0
56
+ end
57
+ end
58
+
59
+ def limit
60
+ return 10 unless pagination?
61
+
62
+ if @params[:page][:size]
63
+ @params[:page][:size].to_i
64
+ else
65
+ 10
66
+ end
67
+ end
68
+
69
+ def pagination?
70
+ @params[:page] && @params[:page][:number]
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,84 @@
1
+ module ForestLiana
2
+ class StripeInvoicesGetter
3
+ attr_accessor :records
4
+
5
+ def initialize(params, secret_key, reference)
6
+ @params = params
7
+ @reference_model, @reference_field = reference_model(reference)
8
+ Stripe.api_key = secret_key
9
+ end
10
+
11
+ def count
12
+ @invoices.try(:total_count) || 0
13
+ end
14
+
15
+ def perform
16
+ query = { limit: limit, offset: offset }
17
+
18
+ if reference_model_id
19
+ resource = @reference_model.find(reference_model_id)
20
+ query[:customer] = resource[@reference_field]
21
+ end
22
+
23
+ query['include[]'] = 'total_count'
24
+ @invoices = fetch_invoices(query)
25
+
26
+ @records = @invoices.data.map do |d|
27
+ d.date = Time.at(d.date).to_datetime
28
+ d.period_start = Time.at(d.period_start).to_datetime
29
+ d.period_end = Time.at(d.period_end).to_datetime
30
+ d.subtotal /= 100
31
+ d.total /= 100
32
+
33
+ query = {}
34
+ query[@reference_field] = d.customer
35
+ d.customer = @reference_model.find_by(query)
36
+
37
+ d
38
+ end
39
+ end
40
+
41
+ def fetch_invoices(params)
42
+ return if reference_model_id && params[:customer].blank?
43
+ Stripe::Invoice.all(params)
44
+ end
45
+
46
+ def reference_model(reference)
47
+ resource_name, reference_field = reference.split('.')
48
+ reference_model = SchemaUtils.find_model_from_table_name(resource_name)
49
+
50
+ [reference_model, reference_field]
51
+ end
52
+
53
+ def reference_model_id
54
+ @params["#{@reference_model.table_name.singularize()}Id"]
55
+ end
56
+
57
+ def offset
58
+ return 0 unless pagination?
59
+
60
+ number = @params[:page][:number]
61
+ if number && number.to_i > 0
62
+ (number.to_i - 1) * limit
63
+ else
64
+ 0
65
+ end
66
+ end
67
+
68
+ def limit
69
+ return 10 unless pagination?
70
+
71
+ if @params[:page][:size]
72
+ @params[:page][:size].to_i
73
+ else
74
+ 10
75
+ end
76
+ end
77
+
78
+ def pagination?
79
+ @params[:page] && @params[:page][:number]
80
+ end
81
+
82
+ end
83
+ end
84
+
@@ -0,0 +1,17 @@
1
+ module ForestLiana
2
+ class StripePaymentRefunder
3
+ def initialize(params)
4
+ @params = params
5
+ Stripe.api_key = params[:parameters][:stripeSecretKey]
6
+ end
7
+
8
+ def perform
9
+ return unless @params[:jsonapis]
10
+
11
+ @params[:jsonapis].each do |jsonapi|
12
+ ch = Stripe::Charge.retrieve(jsonapi[:data][:id])
13
+ ch.refunds.create
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,82 @@
1
+ module ForestLiana
2
+ class StripePaymentsGetter
3
+ attr_accessor :records
4
+
5
+ def initialize(params, secret_key, reference)
6
+ @params = params
7
+ @reference_model, @reference_field = reference_model(reference)
8
+ Stripe.api_key = secret_key
9
+ end
10
+
11
+ def count
12
+ @charges.try(:total_count) || 0
13
+ end
14
+
15
+ def perform
16
+ query = { limit: limit, offset: offset }
17
+
18
+ if reference_model_id
19
+ resource = @reference_model.find(reference_model_id)
20
+ query[:customer] = resource[@reference_field]
21
+ end
22
+
23
+ query['source'] = { object: :card }
24
+ query['include[]'] = 'total_count'
25
+
26
+ @charges = fetch_charges(query)
27
+
28
+ @records = @charges.data.map do |d|
29
+ d.created = Time.at(d.created).to_datetime
30
+ d.amount /= 100
31
+
32
+ query = {}
33
+ query[@reference_field] = d.customer
34
+ d.customer = @reference_model.find_by(query)
35
+
36
+ d
37
+ end
38
+ end
39
+
40
+ def fetch_charges(params)
41
+ return if reference_model_id && params[:customer].blank?
42
+ Stripe::Charge.all(params)
43
+ end
44
+
45
+ def reference_model(reference)
46
+ resource_name, reference_field = reference.split('.')
47
+ reference_model = SchemaUtils.find_model_from_table_name(resource_name)
48
+
49
+ [reference_model, reference_field]
50
+ end
51
+
52
+ def reference_model_id
53
+ @params["#{@reference_model.table_name.singularize()}Id"]
54
+ end
55
+
56
+ def offset
57
+ return 0 unless pagination?
58
+
59
+ number = @params[:page][:number]
60
+ if number && number.to_i > 0
61
+ (number.to_i - 1) * limit
62
+ else
63
+ 0
64
+ end
65
+ end
66
+
67
+ def limit
68
+ return 10 unless pagination?
69
+
70
+ if @params[:page][:size]
71
+ @params[:page][:size].to_i
72
+ else
73
+ 10
74
+ end
75
+ end
76
+
77
+ def pagination?
78
+ @params[:page] && @params[:page][:number]
79
+ end
80
+
81
+ end
82
+ end
data/config/routes.rb CHANGED
@@ -1,4 +1,9 @@
1
1
  ForestLiana::Engine.routes.draw do
2
+ get 'stripe_payments' => 'stripe#payments'
3
+ post 'stripe_payments/refunds' => 'stripe#refund'
4
+ get 'stripe_cards' => 'stripe#cards'
5
+ get 'stripe_invoices' => 'stripe#invoices'
6
+
2
7
  get '/' => 'apimaps#index'
3
8
  get ':collection' => 'resources#index'
4
9
  get ':collection/:id' => 'resources#show'
@@ -1,4 +1,5 @@
1
1
  require 'rack/cors'
2
+ require 'stripe'
2
3
 
3
4
  module ForestLiana
4
5
  class Engine < ::Rails::Engine
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
Binary file
@@ -35730,5 +35730,242 @@ ForestLiana::ResourcesGetterTest: test_StringField_sort_by_field
35730
35730
   (0.2ms) begin transaction
35731
35731
  ---------------------------
35732
35732
  ForestLianaTest: test_truth
35733
+ ---------------------------
35734
+  (0.0ms) rollback transaction
35735
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
35736
+  (0.2ms) begin transaction
35737
+ Fixture Delete (1.5ms) DELETE FROM "belongs_to_fields"
35738
+ Fixture Insert (0.7ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (1, 1, 1)
35739
+ Fixture Insert (0.2ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (2, 2, 1)
35740
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (3, 3, 1)
35741
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (4, 4, 2)
35742
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (5, 5, 2)
35743
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (6, 6, 2)
35744
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (7, 7, 3)
35745
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (8, 8, 3)
35746
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (9, 9, 3)
35747
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (10, 10, 4)
35748
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (11, 11, 4)
35749
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (12, 12, 4)
35750
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (13, 13, 5)
35751
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (14, 14, 5)
35752
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (15, 15, 5)
35753
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (16, 16, 6)
35754
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (17, 17, 6)
35755
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (18, 18, 6)
35756
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (19, 19, 7)
35757
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (20, 20, 7)
35758
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (21, 21, 7)
35759
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (22, 22, 7)
35760
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (23, 23, 8)
35761
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (24, 24, 8)
35762
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (25, 25, 9)
35763
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (26, 26, 9)
35764
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (27, 27, 9)
35765
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (28, 28, 10)
35766
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (29, 29, 10)
35767
+ Fixture Insert (0.1ms) INSERT INTO "belongs_to_fields" ("id", "has_one_field_id", "has_many_field_id") VALUES (30, 30, 10)
35768
+ Fixture Delete (1.0ms) DELETE FROM "has_many_fields"
35769
+ Fixture Insert (0.1ms) INSERT INTO "has_many_fields" ("id") VALUES (1)
35770
+ Fixture Insert (0.1ms) INSERT INTO "has_many_fields" ("id") VALUES (2)
35771
+ Fixture Insert (0.1ms) INSERT INTO "has_many_fields" ("id") VALUES (3)
35772
+ Fixture Insert (0.1ms) INSERT INTO "has_many_fields" ("id") VALUES (4)
35773
+ Fixture Insert (0.1ms) INSERT INTO "has_many_fields" ("id", "has_many_through_field_id") VALUES (5, 3)
35774
+ Fixture Insert (0.1ms) INSERT INTO "has_many_fields" ("id", "has_many_through_field_id") VALUES (6, 2)
35775
+ Fixture Insert (0.1ms) INSERT INTO "has_many_fields" ("id") VALUES (7)
35776
+ Fixture Insert (0.1ms) INSERT INTO "has_many_fields" ("id", "has_many_through_field_id") VALUES (8, 2)
35777
+ Fixture Insert (0.0ms) INSERT INTO "has_many_fields" ("id") VALUES (9)
35778
+ Fixture Insert (0.0ms) INSERT INTO "has_many_fields" ("id") VALUES (10)
35779
+ Fixture Delete (0.5ms) DELETE FROM "has_many_through_fields"
35780
+ Fixture Insert (0.1ms) INSERT INTO "has_many_through_fields" ("id") VALUES (1)
35781
+ Fixture Insert (0.0ms) INSERT INTO "has_many_through_fields" ("id") VALUES (2)
35782
+ Fixture Insert (0.1ms) INSERT INTO "has_many_through_fields" ("id") VALUES (3)
35783
+ Fixture Insert (0.0ms) INSERT INTO "has_many_through_fields" ("id") VALUES (4)
35784
+ Fixture Insert (0.1ms) INSERT INTO "has_many_through_fields" ("id") VALUES (5)
35785
+ Fixture Insert (0.0ms) INSERT INTO "has_many_through_fields" ("id") VALUES (6)
35786
+ Fixture Insert (0.0ms) INSERT INTO "has_many_through_fields" ("id") VALUES (7)
35787
+ Fixture Insert (0.0ms) INSERT INTO "has_many_through_fields" ("id") VALUES (8)
35788
+ Fixture Insert (0.0ms) INSERT INTO "has_many_through_fields" ("id") VALUES (9)
35789
+ Fixture Insert (0.0ms) INSERT INTO "has_many_through_fields" ("id") VALUES (10)
35790
+ Fixture Delete (0.4ms) DELETE FROM "has_one_fields"
35791
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (1)
35792
+ Fixture Insert (0.0ms) INSERT INTO "has_one_fields" ("id") VALUES (2)
35793
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (3)
35794
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (4)
35795
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (5)
35796
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (6)
35797
+ Fixture Insert (0.2ms) INSERT INTO "has_one_fields" ("id") VALUES (7)
35798
+ Fixture Insert (0.2ms) INSERT INTO "has_one_fields" ("id") VALUES (8)
35799
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (9)
35800
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (10)
35801
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (11)
35802
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (12)
35803
+ Fixture Insert (0.2ms) INSERT INTO "has_one_fields" ("id") VALUES (13)
35804
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (14)
35805
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (15)
35806
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (16)
35807
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (17)
35808
+ Fixture Insert (0.0ms) INSERT INTO "has_one_fields" ("id") VALUES (18)
35809
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (19)
35810
+ Fixture Insert (0.0ms) INSERT INTO "has_one_fields" ("id") VALUES (20)
35811
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (21)
35812
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (22)
35813
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (23)
35814
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (24)
35815
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (25)
35816
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (26)
35817
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (27)
35818
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (28)
35819
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (29)
35820
+ Fixture Insert (0.1ms) INSERT INTO "has_one_fields" ("id") VALUES (30)
35821
+ Fixture Delete (0.5ms) DELETE FROM "string_fields"
35822
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (1, 'Test 1')
35823
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (2, 'Test 2')
35824
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (3, 'Test 3')
35825
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (4, 'Test 4')
35826
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (5, 'Test 5')
35827
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (6, 'Test 6')
35828
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (7, 'Test 7')
35829
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (8, 'Test 8')
35830
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (9, 'Test 9')
35831
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (10, 'Test 10')
35832
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (11, 'Test 11')
35833
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (12, 'Test 12')
35834
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (13, 'Test 13')
35835
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (14, 'Test 14')
35836
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (15, 'Test 15')
35837
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (16, 'Test 16')
35838
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (17, 'Test 17')
35839
+ Fixture Insert (0.0ms) INSERT INTO "string_fields" ("id", "field") VALUES (18, 'Test 18')
35840
+ Fixture Insert (0.0ms) INSERT INTO "string_fields" ("id", "field") VALUES (19, 'Test 19')
35841
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (20, 'Test 20')
35842
+ Fixture Insert (0.0ms) INSERT INTO "string_fields" ("id", "field") VALUES (21, 'Test 21')
35843
+ Fixture Insert (0.0ms) INSERT INTO "string_fields" ("id", "field") VALUES (22, 'Test 22')
35844
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (23, 'Test 23')
35845
+ Fixture Insert (0.0ms) INSERT INTO "string_fields" ("id", "field") VALUES (24, 'Test 24')
35846
+ Fixture Insert (0.0ms) INSERT INTO "string_fields" ("id", "field") VALUES (25, 'Test 25')
35847
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (26, 'Test 26')
35848
+ Fixture Insert (0.0ms) INSERT INTO "string_fields" ("id", "field") VALUES (27, 'Test 27')
35849
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (28, 'Test 28')
35850
+ Fixture Insert (0.1ms) INSERT INTO "string_fields" ("id", "field") VALUES (29, 'Test 29')
35851
+ Fixture Insert (0.0ms) INSERT INTO "string_fields" ("id", "field") VALUES (30, 'Test 30')
35852
+  (1.0ms) commit transaction
35853
+  (0.0ms) begin transaction
35854
+ --------------------------------------------------------------------------
35855
+ ForestLiana::SchemaAdapterTest: test_Integer_should_have_the_type_`Number`
35856
+ --------------------------------------------------------------------------
35857
+  (0.1ms) rollback transaction
35858
+  (0.1ms) begin transaction
35859
+ ------------------------------------------------------------------------
35860
+ ForestLiana::SchemaAdapterTest: test_Float_should_have_the_type_`Number`
35861
+ ------------------------------------------------------------------------
35862
+  (0.1ms) rollback transaction
35863
+  (0.1ms) begin transaction
35864
+ ---------------------------------------------------------------------
35865
+ ForestLiana::SchemaAdapterTest: test_Date_should_have_the_type_`Date`
35866
+ ---------------------------------------------------------------------
35867
+  (0.1ms) rollback transaction
35868
+  (0.0ms) begin transaction
35869
+ ---------------------------------------------------------------------------
35870
+ ForestLiana::SchemaAdapterTest: test_Boolean_should_have_the_type_`Boolean`
35871
+ ---------------------------------------------------------------------------
35872
+  (0.1ms) rollback transaction
35873
+  (0.1ms) begin transaction
35874
+ ------------------------------------------------------------------------------------
35875
+ ForestLiana::SchemaAdapterTest: test_belongsTo_relationhip_with_specified_class_name
35876
+ ------------------------------------------------------------------------------------
35877
+  (0.1ms) rollback transaction
35878
+  (0.1ms) begin transaction
35879
+ -----------------------------------------------------------
35880
+ ForestLiana::SchemaAdapterTest: test_belongsTo_relationship
35881
+ -----------------------------------------------------------
35882
+  (0.1ms) rollback transaction
35883
+  (0.1ms) begin transaction
35884
+ -------------------------------------------------------------------------
35885
+ ForestLiana::SchemaAdapterTest: test_DateTime_should_have_the_type_`Date`
35886
+ -------------------------------------------------------------------------
35887
+  (0.1ms) rollback transaction
35888
+  (0.1ms) begin transaction
35889
+ --------------------------------------------------------------------------
35890
+ ForestLiana::SchemaAdapterTest: test_Decimal_should_have_the_type_`Number`
35891
+ --------------------------------------------------------------------------
35892
+  (0.1ms) rollback transaction
35893
+  (0.1ms) begin transaction
35894
+ ----------------------------------------------------------------------------------
35895
+ ForestLiana::SchemaAdapterTest: test_hasMany_relationhip_with_specified_class_name
35896
+ ----------------------------------------------------------------------------------
35897
+  (0.0ms) rollback transaction
35898
+  (0.1ms) begin transaction
35899
+ --------------------------------------------------------
35900
+ ForestLiana::SchemaAdapterTest: test_hasOne_relationship
35901
+ --------------------------------------------------------
35902
+  (0.1ms) rollback transaction
35903
+  (0.1ms) begin transaction
35904
+ ---------------------------------------------------------
35905
+ ForestLiana::SchemaAdapterTest: test_hasMany_relationship
35906
+ ---------------------------------------------------------
35907
+  (0.1ms) rollback transaction
35908
+  (0.1ms) begin transaction
35909
+ -------------------------------------------------------------------------
35910
+ ForestLiana::SchemaAdapterTest: test_String_should_have_the_type_`String`
35911
+ -------------------------------------------------------------------------
35912
+  (0.1ms) rollback transaction
35913
+  (0.0ms) begin transaction
35914
+ -----------------------------------------------------------------
35915
+ ForestLiana::ResourcesGetterTest: test_StringField_page_2_size_10
35916
+ -----------------------------------------------------------------
35917
+ StringField Load (0.3ms) SELECT "string_fields".* FROM "string_fields" ORDER BY string_fields.id DESC LIMIT 10 OFFSET 10
35918
+  (0.1ms) SELECT COUNT(*) FROM "string_fields"
35919
+  (0.1ms) rollback transaction
35920
+  (0.0ms) begin transaction
35921
+ -----------------------------------------------------------------------
35922
+ ForestLiana::ResourcesGetterTest: test_Sort_by_a_belongs_to_association
35923
+ -----------------------------------------------------------------------
35924
+ SQL (0.3ms) SELECT "belongs_to_fields"."id" AS t0_r0, "belongs_to_fields"."has_one_field_id" AS t0_r1, "belongs_to_fields"."has_many_class_name_field_id" AS t0_r2, "belongs_to_fields"."has_many_field_id" AS t0_r3, "has_one_fields"."id" AS t1_r0, "has_many_fields"."id" AS t2_r0, "has_many_fields"."has_many_through_field_id" AS t2_r1, "has_many_class_name_fields"."id" AS t3_r0 FROM "belongs_to_fields" LEFT OUTER JOIN "has_one_fields" ON "has_one_fields"."id" = "belongs_to_fields"."has_one_field_id" LEFT OUTER JOIN "has_many_fields" ON "has_many_fields"."id" = "belongs_to_fields"."has_many_field_id" LEFT OUTER JOIN "has_many_class_name_fields" ON "has_many_class_name_fields"."id" = "belongs_to_fields"."has_many_class_name_field_id" ORDER BY has_one_fields.id ASC LIMIT 10 OFFSET 0
35925
+  (0.1ms) SELECT COUNT(*) FROM "belongs_to_fields"
35926
+  (0.1ms) rollback transaction
35927
+  (0.1ms) begin transaction
35928
+ --------------------------------------------------------------------
35929
+ ForestLiana::ResourcesGetterTest: test_Sort_by_a_has_one_association
35930
+ --------------------------------------------------------------------
35931
+ SQL (0.6ms) SELECT "has_one_fields"."id" AS t0_r0, "belongs_to_fields"."id" AS t1_r0, "belongs_to_fields"."has_one_field_id" AS t1_r1, "belongs_to_fields"."has_many_class_name_field_id" AS t1_r2, "belongs_to_fields"."has_many_field_id" AS t1_r3, "belongs_to_class_name_fields"."id" AS t2_r0, "belongs_to_class_name_fields"."foo_id" AS t2_r1 FROM "has_one_fields" LEFT OUTER JOIN "belongs_to_fields" ON "belongs_to_fields"."has_one_field_id" = "has_one_fields"."id" LEFT OUTER JOIN "belongs_to_class_name_fields" ON "belongs_to_class_name_fields"."foo_id" = "has_one_fields"."id" ORDER BY belongs_to_fields.id DESC LIMIT 10 OFFSET 0
35932
+  (0.1ms) SELECT COUNT(*) FROM "has_one_fields"
35933
+  (0.1ms) rollback transaction
35934
+  (0.0ms) begin transaction
35935
+ -----------------------------------------------------------------------------
35936
+ ForestLiana::ResourcesGetterTest: test_Sort_by_a_has_many_through_association
35937
+ -----------------------------------------------------------------------------
35938
+ HasManyThroughField Load (0.3ms) SELECT has_many_through_fields.*,
35939
+ COUNT(belongs_to_fields.id) has_many_count FROM "has_many_through_fields" LEFT OUTER JOIN "has_many_fields" ON "has_many_fields"."has_many_through_field_id" = "has_many_through_fields"."id" LEFT OUTER JOIN "belongs_to_fields" ON "belongs_to_fields"."has_many_field_id" = "has_many_fields"."id" GROUP BY has_many_through_fields.id ORDER BY has_many_count DESC LIMIT 10 OFFSET 0
35940
+ HasManyField Load (0.2ms) SELECT "has_many_fields".* FROM "has_many_fields" WHERE "has_many_fields"."has_many_through_field_id" IN (2, 3, 1, 4, 5, 6, 7, 8, 9, 10)
35941
+  (0.0ms) SELECT COUNT(*) FROM "has_many_through_fields"
35942
+  (0.0ms) rollback transaction
35943
+  (0.1ms) begin transaction
35944
+ -----------------------------------------------------------------
35945
+ ForestLiana::ResourcesGetterTest: test_StringField_page_1_size_15
35946
+ -----------------------------------------------------------------
35947
+ StringField Load (0.1ms) SELECT "string_fields".* FROM "string_fields" ORDER BY string_fields.id DESC LIMIT 15 OFFSET 0
35948
+  (0.0ms) SELECT COUNT(*) FROM "string_fields"
35949
+  (0.0ms) rollback transaction
35950
+  (0.1ms) begin transaction
35951
+ ---------------------------------------------------------------------
35952
+ ForestLiana::ResourcesGetterTest: test_Sort_by_a_has_many_association
35953
+ ---------------------------------------------------------------------
35954
+ HasManyField Load (0.3ms) SELECT has_many_fields.*,
35955
+ COUNT(belongs_to_fields.id) has_many_count FROM "has_many_fields" LEFT OUTER JOIN "belongs_to_fields" ON "belongs_to_fields"."has_many_field_id" = "has_many_fields"."id" GROUP BY has_many_fields.id ORDER BY has_many_count DESC LIMIT 10 OFFSET 0
35956
+ BelongsToField Load (0.2ms) SELECT "belongs_to_fields".* FROM "belongs_to_fields" WHERE "belongs_to_fields"."has_many_field_id" IN (7, 1, 2, 3, 4, 5, 6, 9, 10, 8)
35957
+ HasManyThroughField Load (0.3ms) SELECT "has_many_through_fields".* FROM "has_many_through_fields" WHERE "has_many_through_fields"."id" IN (3, 2)
35958
+  (0.1ms) SELECT COUNT(*) FROM "has_many_fields"
35959
+  (0.1ms) rollback transaction
35960
+  (0.1ms) begin transaction
35961
+ ----------------------------------------------------------------
35962
+ ForestLiana::ResourcesGetterTest: test_StringField_sort_by_field
35963
+ ----------------------------------------------------------------
35964
+ StringField Load (0.3ms) SELECT "string_fields".* FROM "string_fields" ORDER BY field DESC LIMIT 10 OFFSET 0
35965
+  (0.1ms) SELECT COUNT(*) FROM "string_fields"
35966
+  (0.1ms) rollback transaction
35967
+  (0.1ms) begin transaction
35968
+ ---------------------------
35969
+ ForestLianaTest: test_truth
35733
35970
  ---------------------------
35734
35971
   (0.0ms) rollback transaction
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-25 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: stripe
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Forest Rails Liana
84
98
  email:
85
99
  - sandro@munda.me
@@ -96,16 +110,24 @@ files:
96
110
  - app/controllers/forest_liana/apimaps_controller.rb
97
111
  - app/controllers/forest_liana/application_controller.rb
98
112
  - app/controllers/forest_liana/resources_controller.rb
113
+ - app/controllers/forest_liana/stripe_controller.rb
99
114
  - app/deserializers/forest_liana/resource_deserializer.rb
100
115
  - app/helpers/forest_liana/application_helper.rb
101
116
  - app/models/forest_liana/collection.rb
102
117
  - app/serializers/forest_liana/apimap_serializer.rb
103
118
  - app/serializers/forest_liana/serializer_factory.rb
119
+ - app/serializers/forest_liana/stripe_card_serializer.rb
120
+ - app/serializers/forest_liana/stripe_invoice_serializer.rb
121
+ - app/serializers/forest_liana/stripe_payment_serializer.rb
104
122
  - app/services/forest_liana/resource_getter.rb
105
123
  - app/services/forest_liana/resources_getter.rb
106
124
  - app/services/forest_liana/schema_adapter.rb
107
125
  - app/services/forest_liana/schema_utils.rb
108
126
  - app/services/forest_liana/search_query_builder.rb
127
+ - app/services/forest_liana/stripe_cards_getter.rb
128
+ - app/services/forest_liana/stripe_invoices_getter.rb
129
+ - app/services/forest_liana/stripe_payment_refunder.rb
130
+ - app/services/forest_liana/stripe_payments_getter.rb
109
131
  - app/views/layouts/forest_liana/application.html.erb
110
132
  - config/initializers/arel-helpers.rb
111
133
  - config/initializers/mimetype.rb