forest_liana 1.1.15 → 1.1.16

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: a9ddcb2a3b21734d0089682d98f29e6dba11c0e6
4
- data.tar.gz: 9677980c020592ac28fc506941a192d495a3b29e
3
+ metadata.gz: d8f236c05a4fda3ca63553fbe3bdc740c16a7199
4
+ data.tar.gz: ea83ef6b9644a7598356e7a1c0a5948c4eb6332a
5
5
  SHA512:
6
- metadata.gz: 69b1b1798846619b230ea7ddb610459b8accdbb04068c9de8cefb6d5bf5c2f3c8e5d2da9cc42868648209c481fe58bae2431cd276777da4a9061f277dffb1c8c
7
- data.tar.gz: ddb0ac09089dcdf41758671d4b0e9e2a2777d42d64fe79f44f35d7a70fe12a907564ffa7888b77b7dac77770efb0376a03416a456e6b92eb56afac25356dfc2c
6
+ metadata.gz: 0f974c93a1fe87bc596ba6684f179dbe7bcec36e4b171d29215cf2c16b93ba1d254730ae1b7463245a5c9dba0655dc37f100eb7f0f3ddab599c6c32650012531
7
+ data.tar.gz: 0894696de4d8986d7bcc9936cb3087e28e5197bb7d8a4db91867bdc1a3ae5f6796e504ad9ac8b72347a1407361528fb7b9d9019654ee8f6e640ea194cf9e0e89
@@ -28,6 +28,10 @@ module ForestLiana
28
28
 
29
29
  def fetch_cards(customer, params)
30
30
  @cards = Stripe::Customer.retrieve(customer).sources.all(params)
31
+ if @cards.blank?
32
+ @records = []
33
+ return
34
+ end
31
35
 
32
36
  @records = @cards.data.map do |d|
33
37
  query = {}
@@ -22,6 +22,10 @@ module ForestLiana
22
22
 
23
23
  query['include[]'] = 'total_count'
24
24
  @invoices = fetch_invoices(query)
25
+ if @invoices.blank?
26
+ @records = []
27
+ return
28
+ end
25
29
 
26
30
  @records = @invoices.data.map do |d|
27
31
  d.date = Time.at(d.date).to_datetime
@@ -24,6 +24,10 @@ module ForestLiana
24
24
  query['include[]'] = 'total_count'
25
25
 
26
26
  @charges = fetch_charges(query)
27
+ if @charges.blank?
28
+ @records = []
29
+ return
30
+ end
27
31
 
28
32
  @records = @charges.data.map do |d|
29
33
  d.created = Time.at(d.created).to_datetime
@@ -25,46 +25,48 @@ module ForestLiana
25
25
  model.try(:table_exists?)
26
26
  end
27
27
 
28
- # Monkey patch the find_serializer_class_name method to specify the good
29
- # serializer to use.
28
+ # Monkey patch the find_serializer_class_name method to specify the
29
+ # good serializer to use.
30
30
  JSONAPI::Serializer.class_eval do
31
31
  def self.find_serializer_class_name(obj)
32
32
  SerializerFactory.get_serializer_name(obj.class)
33
33
  end
34
34
  end
35
- end
36
35
 
37
- if ForestLiana.jwt_signing_key
38
- forest_url = ENV['FOREST_URL'] ||
39
- 'https://forestadmin-server.herokuapp.com';
36
+ if ForestLiana.jwt_signing_key
37
+ forest_url = ENV['FOREST_URL'] ||
38
+ 'https://forestadmin-server.herokuapp.com';
40
39
 
41
- apimaps = []
42
- SchemaUtils.tables_names.map do |table_name|
43
- model = SchemaUtils.find_model_from_table_name(table_name)
44
- apimaps << SchemaAdapter.new(model).perform if model.try(:table_exists?)
45
- end
40
+ apimaps = []
41
+ SchemaUtils.tables_names.map do |table_name|
42
+ model = SchemaUtils.find_model_from_table_name(table_name)
43
+ if model.try(:table_exists?)
44
+ apimaps << SchemaAdapter.new(model).perform
45
+ end
46
+ end
46
47
 
47
- liana_version = Gem::Specification.find_by_name('forest_liana')
48
- .version.to_s
49
- json = JSONAPI::Serializer.serialize(apimaps, {
50
- is_collection: true,
51
- meta: { liana: 'forest-rails', liana_version: liana_version }
52
- })
48
+ liana_version = Gem::Specification.find_by_name('forest_liana')
49
+ .version.to_s
50
+ json = JSONAPI::Serializer.serialize(apimaps, {
51
+ is_collection: true,
52
+ meta: { liana: 'forest-rails', liana_version: liana_version }
53
+ })
53
54
 
54
55
 
55
- uri = URI.parse("#{forest_url}/forest/apimaps")
56
- http = Net::HTTP.new(uri.host, uri.port)
57
- http.use_ssl = true if forest_url.start_with?('https')
58
- http.start do |client|
59
- request = Net::HTTP::Post.new(uri.path)
60
- request.body = json.to_json
61
- request['Content-Type'] = 'application/json'
62
- request['forest-secret-key'] = ForestLiana.jwt_signing_key
63
- response = client.request(request)
56
+ uri = URI.parse("#{forest_url}/forest/apimaps")
57
+ http = Net::HTTP.new(uri.host, uri.port)
58
+ http.use_ssl = true if forest_url.start_with?('https')
59
+ http.start do |client|
60
+ request = Net::HTTP::Post.new(uri.path)
61
+ request.body = json.to_json
62
+ request['Content-Type'] = 'application/json'
63
+ request['forest-secret-key'] = ForestLiana.jwt_signing_key
64
+ response = client.request(request)
64
65
 
65
- if response.is_a?(Net::HTTPNotFound)
66
- logger.warn "Forest cannot find your project secret key. " \
67
- "Please, run `rails g forest_liana:install`."
66
+ if response.is_a?(Net::HTTPNotFound)
67
+ logger.warn "Forest cannot find your project secret key. " \
68
+ "Please, run `rails g forest_liana:install`."
69
+ end
68
70
  end
69
71
  end
70
72
  end
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "1.1.15"
2
+ VERSION = "1.1.16"
3
3
  end
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.1.15
4
+ version: 1.1.16
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-11-30 00:00:00.000000000 Z
11
+ date: 2015-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails