firmapi 0.1 → 0.1.2

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: 83b3f1632b676cb34fa0dd1d5e07d4b059becc66
4
- data.tar.gz: 96d491c658248919a96171211f41dce4c4310a77
3
+ metadata.gz: fd107cae8498f72c5c589eb7f5aac3a2d498aed0
4
+ data.tar.gz: 5bbddbc55ea4b9ad0372a87ee4d82256e4511def
5
5
  SHA512:
6
- metadata.gz: caa57ef54818f727cefca381642e2c0fd60b2628300c79003955ef8393dcd367d56af7aedee41f56fc1830d19ee5e19043cd2fb0d404af055bc9bfc4ea258a01
7
- data.tar.gz: f70f67e4a93bc604b627be92134b775e1b0296f97f6af893ee4a605b690da7d73091b50b7c0e510e16130708605a71460786280a90b3a4a8d14e8ed7092ae50a
6
+ metadata.gz: 00511e1b43993c5babfee4ea3e006b1e4fa34db0cc99c2263d00c7d18b752404bbed31badc5a97ac15f1b72cea2438f06b72b1fd5cd77b2e1f7435d568953180
7
+ data.tar.gz: 197ea5237085fb3a5676b1ba4faeec450bf1fa143748e86904c282c48174b85c1425759694bfd73f6c4e776737f05fb5ac98d5cfe304be42342a776c47728304
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
7
6
  InstalledFiles
8
7
  _yardoc
9
8
  coverage
data/Gemfile.lock ADDED
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ firmapi (0.1.1)
5
+ faraday (~> 0.9)
6
+ faraday_middleware (~> 0.9)
7
+ virtus (~> 1.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.3.6)
13
+ axiom-types (0.1.1)
14
+ descendants_tracker (~> 0.0.4)
15
+ ice_nine (~> 0.11.0)
16
+ thread_safe (~> 0.3, >= 0.3.1)
17
+ coercible (1.0.0)
18
+ descendants_tracker (~> 0.0.1)
19
+ crack (0.4.2)
20
+ safe_yaml (~> 1.0.0)
21
+ descendants_tracker (0.0.4)
22
+ thread_safe (~> 0.3, >= 0.3.1)
23
+ diff-lcs (1.2.5)
24
+ equalizer (0.0.9)
25
+ faraday (0.9.0)
26
+ multipart-post (>= 1.2, < 3)
27
+ faraday_middleware (0.9.1)
28
+ faraday (>= 0.7.4, < 0.10)
29
+ ice_nine (0.11.0)
30
+ multipart-post (2.0.0)
31
+ rake (10.1.1)
32
+ rspec (2.99.0)
33
+ rspec-core (~> 2.99.0)
34
+ rspec-expectations (~> 2.99.0)
35
+ rspec-mocks (~> 2.99.0)
36
+ rspec-core (2.99.0)
37
+ rspec-expectations (2.99.0)
38
+ diff-lcs (>= 1.1.3, < 2.0)
39
+ rspec-mocks (2.99.0)
40
+ safe_yaml (1.0.3)
41
+ thread_safe (0.3.4)
42
+ vcr (2.9.2)
43
+ virtus (1.0.2)
44
+ axiom-types (~> 0.1)
45
+ coercible (~> 1.0)
46
+ descendants_tracker (~> 0.0.3)
47
+ equalizer (~> 0.0.9)
48
+ webmock (1.18.0)
49
+ addressable (>= 2.3.6)
50
+ crack (>= 0.3.2)
51
+
52
+ PLATFORMS
53
+ ruby
54
+
55
+ DEPENDENCIES
56
+ bundler (~> 1.3)
57
+ firmapi!
58
+ rake (~> 10.1.0)
59
+ rspec (~> 2.99)
60
+ vcr (~> 2.9)
61
+ webmock (~> 1.18)
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Firmapi
2
+ [![Code Climate](https://codeclimate.com/github/EtienneDepaulis/firmapi.png)](https://codeclimate.com/github/EtienneDepaulis/firmapi) [![CircleCI](https://circleci.com/gh/EtienneDepaulis/firmapi.png)](https://circleci.com/gh/etiennedepaulis/firmapi)
2
3
 
3
4
  Firmapi is a ruby client for [Firmapi](https://firmapi.com/) JSON API.
4
5
 
@@ -34,9 +35,22 @@ calling Firmapi.configure like so:
34
35
 
35
36
  company = Firmapi::Company.find_by_siren!(480470152)
36
37
  company.name # => "EVANGELINA"
37
-
38
+
38
39
  Firmapi::Company.find_by_siren!("INVALID SIREN") # => Firmapi::Company::NoCompanyFound: 'No company was found with the siren 'INVALID SIREN'.'
39
40
 
41
+ #### Using the postal_code
42
+
43
+ companies = Firmapi::Companies.where(postal_code: 69)
44
+ companies.results # => 103307
45
+ companies.number_of_pages # => 1033
46
+ companies.to_a # => [Company1, Company2, ...]
47
+
48
+ More info on search parameters [here](https://firmapi.com/docs/call/search).
49
+
50
+ You can also navigate using the `:next_page` method:
51
+
52
+ companies.next_page
53
+ companies.page = 2
40
54
 
41
55
  ## Contributing
42
56
 
data/firmapi.gemspec CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |spec|
7
7
  spec.version = Firmapi::VERSION
8
8
  spec.authors = ["Etienne Depaulis"]
9
9
  spec.email = ["etienne.depaulis@gmail.com"]
10
- spec.description = %q{Firmapi is a ruby client for www.firmapi.com}
11
- spec.summary = %q{Firmapi is a ruby client for www.firmapi.com}
10
+ spec.description = %q{Firmapi is a ruby client for www.firmapi.com JSON API}
11
+ spec.summary = %q{Firmapi is a ruby client for www.firmapi.com JSON API}
12
12
  spec.homepage = ""
13
13
  spec.license = "MIT"
14
14
 
@@ -0,0 +1,28 @@
1
+ module Firmapi
2
+ class API
3
+
4
+ def get(url, params)
5
+ params = default_params.merge params
6
+
7
+ connexion.get api_url(url), params
8
+ end
9
+
10
+ private
11
+
12
+ def connexion
13
+ @connexion ||= Faraday.new(url: 'https://firmapi.com') do |faraday|
14
+ faraday.response :json, content_type: /\bjson$/
15
+ faraday.adapter Faraday.default_adapter
16
+ end
17
+ end
18
+
19
+ def default_params
20
+ { api_key: Firmapi.configuration.api_key }
21
+ end
22
+
23
+ def api_url(url)
24
+ "/api/v1#{url}"
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,49 @@
1
+ module Firmapi
2
+ class Companies
3
+
4
+ attr_reader :results, :size, :page, :number_of_pages, :params, :list
5
+
6
+ def initialize(options, params)
7
+ @results = options["results"]
8
+ @size = options["size"]
9
+ @page = options["page"]
10
+ @number_of_pages = options["number_of_pages"]
11
+ @list = []
12
+ @params = params
13
+ end
14
+
15
+ def add_company(company)
16
+ @list << company
17
+ end
18
+
19
+ def to_a
20
+ @list
21
+ end
22
+
23
+ def next_page
24
+ params[:page] = page + 1
25
+
26
+ Companies.where(params)
27
+ end
28
+
29
+ def self.where(params)
30
+
31
+ @params = params
32
+
33
+ response = API.new.get '/companies', params
34
+
35
+ if response.status == 200
36
+ json = response.body
37
+
38
+ companies = self.new(json["result"]["search"], params)
39
+
40
+ json["result"]["list"].each do |company_info|
41
+ companies.add_company Firmapi::Company.new company_info
42
+ end
43
+
44
+ companies
45
+ end
46
+ end
47
+
48
+ end
49
+ end
@@ -1,7 +1,3 @@
1
- require 'virtus'
2
- require 'faraday'
3
- require 'faraday_middleware'
4
-
5
1
  module Firmapi
6
2
  class Company
7
3
  include Virtus.model
@@ -23,12 +19,8 @@ module Firmapi
23
19
  attribute :website, String
24
20
 
25
21
  def self.find_by_siren!(siren)
26
- conn = Faraday.new(url: 'https://firmapi.com') do |faraday|
27
- faraday.response :json, content_type: /\bjson$/
28
- faraday.adapter Faraday.default_adapter
29
- end
30
22
 
31
- response = conn.get '/api/v1/company', { siren: siren, api_key: Firmapi.configuration.api_key}
23
+ response = API.new.get '/company', { siren: siren }
32
24
 
33
25
  if response.status == 200
34
26
  json = response.body
@@ -1,3 +1,3 @@
1
1
  module Firmapi
2
- VERSION = "0.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/firmapi.rb CHANGED
@@ -2,7 +2,13 @@ require "firmapi/version"
2
2
 
3
3
  module Firmapi
4
4
 
5
+ require 'virtus'
6
+ require 'faraday'
7
+ require 'faraday_middleware'
8
+
9
+ require 'firmapi/api'
5
10
  require 'firmapi/configuration'
11
+ require 'firmapi/companies'
6
12
  require 'firmapi/company'
7
13
 
8
14
  end
@@ -0,0 +1,144 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://firmapi.com/api/v1/companies?api_key=secret_api_key&postal_code=69
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - ! '*/*'
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: !binary |-
20
+ T0s=
21
+ headers:
22
+ !binary "U2VydmVy":
23
+ - !binary |-
24
+ bmdpbngvMS40LjEgKFVidW50dSk=
25
+ !binary "RGF0ZQ==":
26
+ - !binary |-
27
+ RnJpLCAwNiBKdW4gMjAxNCAxNTo1NToxMyBHTVQ=
28
+ !binary "Q29udGVudC1UeXBl":
29
+ - !binary |-
30
+ YXBwbGljYXRpb24vanNvbjsgY2hhcnNldD11dGYtOA==
31
+ !binary "VHJhbnNmZXItRW5jb2Rpbmc=":
32
+ - !binary |-
33
+ Y2h1bmtlZA==
34
+ !binary "Q29ubmVjdGlvbg==":
35
+ - !binary |-
36
+ a2VlcC1hbGl2ZQ==
37
+ !binary "WC1GcmFtZS1PcHRpb25z":
38
+ - !binary |-
39
+ U0FNRU9SSUdJTg==
40
+ !binary "WC1Yc3MtUHJvdGVjdGlvbg==":
41
+ - !binary |-
42
+ MTsgbW9kZT1ibG9jaw==
43
+ !binary "WC1Db250ZW50LVR5cGUtT3B0aW9ucw==":
44
+ - !binary |-
45
+ bm9zbmlmZg==
46
+ !binary "RXRhZw==":
47
+ - !binary |-
48
+ ImY3MGU1ZGEyMzlmN2JjNGJkYTgzOTNiOWViMjE3N2U3Ig==
49
+ !binary "Q2FjaGUtQ29udHJvbA==":
50
+ - !binary |-
51
+ bWF4LWFnZT0wLCBwcml2YXRlLCBtdXN0LXJldmFsaWRhdGU=
52
+ !binary "U2V0LUNvb2tpZQ==":
53
+ - !binary |-
54
+ cmVxdWVzdF9tZXRob2Q9R0VUOyBwYXRoPS8=
55
+ !binary "WC1SZXF1ZXN0LUlk":
56
+ - !binary |-
57
+ Njg0NzVkZDEtNTlkOS00MzA2LTkzYzItMzUzMGI3MGIyZGJi
58
+ !binary "WC1SdW50aW1l":
59
+ - !binary |-
60
+ MC4xNTYxMzE=
61
+ body:
62
+ encoding: UTF-8
63
+ string: ! '{"input":{"postal_code":"69","page":1},"result":{"search":{"results":103307,"size":100,"page":1,"number_of_pages":1033},"list":[{"siren":"527810279","name":"C.M.","postal_code":"69960","naf_code":"5610A"},{"siren":"522171016","name":"515
64
+ Store France","postal_code":"69009","naf_code":"7311Z"},{"siren":"528465990","name":"U
65
+ Link","postal_code":"69410","naf_code":"6110Z"},{"siren":"454007725","name":"U
66
+ Lan Technologies","postal_code":"69004","naf_code":"9511Z"},{"siren":"520276031","name":"Allo
67
+ Syndic","postal_code":"69428","naf_code":"6832A"},{"siren":"504008772","name":"Chagny
68
+ Pere Et Fils S A R L","postal_code":"69005","naf_code":"4331Z"},{"siren":"491008629","name":"La
69
+ Terrasse Des Quatre Saisons","postal_code":"69460","naf_code":"5610A"},{"siren":"409184017","name":"Entreprise
70
+ Bost Pere Et Fils","postal_code":"69170","naf_code":"4312A"},{"siren":"409196011","name":"Studio
71
+ Anatole Editions","postal_code":"69001","naf_code":"5920Z"},{"siren":"522213768","name":"Pgnf
72
+ Plomberie","postal_code":"69360","naf_code":"4322A"},{"siren":"509822425","name":"Styl
73
+ MaÎtrise D''oeuvre","postal_code":"69007","naf_code":"7112B"},{"siren":"521539908","name":"Transports
74
+ Gte","postal_code":"69460","naf_code":"4941B"},{"siren":"452278039","name":"Sarl
75
+ Ebol","postal_code":"69670","naf_code":"8130Z"},{"siren":"513496174","name":"Cbs
76
+ Prestige","postal_code":"69680","naf_code":"4743Z"},{"siren":"401442744","name":"Le
77
+ Bois Debout","postal_code":"69005","naf_code":"4779Z"},{"siren":"531705218","name":"Le
78
+ Sommelier De La Tour","postal_code":"69890","naf_code":"4725Z"},{"siren":"501938740","name":"Sg
79
+ Expertise","postal_code":"69220","naf_code":"6920Z"},{"siren":"514166982","name":"LA
80
+ BOUTIQUE D''INAE","postal_code":"69400","naf_code":"4751Z"},{"siren":"400666988","name":"Etiq''b","postal_code":"69730","naf_code":"7112B"},{"siren":"527663629","name":"Le
81
+ Rousseau","postal_code":"69350","naf_code":"5610A"},{"siren":"513070128","name":"Herboristerie
82
+ De Lyon La Croix Rousse","postal_code":"69004","naf_code":"4729Z"},{"siren":"384267977","name":"Verot
83
+ Girodet","postal_code":"69530","naf_code":"4619B"},{"siren":"523210979","name":"AU
84
+ TOOLEYS","postal_code":"69005","naf_code":"5610A"},{"siren":"324971738","name":"Ceramdent","postal_code":"69003","naf_code":"3250A"},{"siren":"420400350","name":"Century
85
+ 21 Sat","postal_code":"69008","naf_code":"6831Z"},{"siren":"538845884","name":"Mdm
86
+ Developpement","postal_code":"69004","naf_code":"6420Z"},{"siren":"478967151","name":"Persona
87
+ Grata","postal_code":"69006","naf_code":"7311Z"},{"siren":"480314988","name":"Probati","postal_code":"69440","naf_code":"4334Z"},{"siren":"450896774","name":"Societe
88
+ Nouvelle Prima Froid","postal_code":"69360","naf_code":"3320B"},{"siren":"522295062","name":"Le
89
+ San Marco","postal_code":"69003","naf_code":"5610A"},{"siren":"527691679","name":"Fill
90
+ Up Media","postal_code":"69100","naf_code":"7312Z"},{"siren":"517612099","name":"Orcalam","postal_code":"69440","naf_code":"6420Z"},{"siren":"523573780","name":"Da
91
+ Restos","postal_code":"69001","naf_code":"6420Z"},{"siren":"508018371","name":"Cornaton
92
+ Sas","postal_code":"69220","naf_code":"6420Z"},{"siren":"395192800","name":"Fic
93
+ Sem","postal_code":"69210","naf_code":"4669B"},{"siren":"488862426","name":"Mgc
94
+ Services","postal_code":"69290","naf_code":"6420Z"},{"siren":"538698812","name":"Participation
95
+ Minodier","postal_code":"69490","naf_code":"6420Z"},{"siren":"438550568","name":"Sarl
96
+ Niglo Clean","postal_code":"69670","naf_code":"8121Z"},{"siren":"450357876","name":"L''ARDOISE
97
+ GOURMANDE","postal_code":"69170","naf_code":"5610A"},{"siren":"499151132","name":"Eurl
98
+ Leonet Electromenager","postal_code":"69610","naf_code":"9522Z"},{"siren":"504382466","name":"First
99
+ Price Immobilier","postal_code":"69007","naf_code":"6831Z"},{"siren":"725480230","name":"Chatelard
100
+ Gestion","postal_code":"69170","naf_code":"1320Z"},{"siren":"521820654","name":"Pizzalina","postal_code":"69008","naf_code":"5610A"},{"siren":"511235426","name":"NONNA
101
+ CARMELA","postal_code":"69100","naf_code":"5610A"},{"siren":"503381550","name":"Confortech","postal_code":"69220","naf_code":"8559A"},{"siren":"487464372","name":"Mpl
102
+ Vision","postal_code":"69110","naf_code":"4649Z"},{"siren":"337550677","name":"Sforza
103
+ Giuseppe Coiffeur Createur","postal_code":"69100","naf_code":"9602A"},{"siren":"488063108","name":"Fashion
104
+ Minut''professional","postal_code":"69120","naf_code":"9602A"},{"siren":"444908982","name":"Oretal","postal_code":"69100","naf_code":"6420Z"},{"siren":"517495396","name":"RTTP","postal_code":"69300","naf_code":"4312A"},{"siren":"750556367","name":"Services
105
+ Lyon Demenagements","postal_code":"69330","naf_code":"4942Z"},{"siren":"489567297","name":"K.R.S.
106
+ Primeurs","postal_code":"69700","naf_code":"4781Z"},{"siren":"407663624","name":"Bolpato
107
+ Meraud","postal_code":"69600","naf_code":"4399C"},{"siren":"500308986","name":"Incitif
108
+ Diffusion","postal_code":"69250","naf_code":"9602A"},{"siren":"480297431","name":"DIONYSOS","postal_code":"69006","naf_code":"5610A"},{"siren":"450860143","name":"ESTEV''
109
+ KAPLAN","postal_code":"69007","naf_code":"9602A"},{"siren":"351795737","name":"Snc
110
+ Lavoisier","postal_code":"69006","naf_code":"6820A"},{"siren":"441763133","name":"Art''cad","postal_code":"69140","naf_code":"4649Z"},{"siren":"518800461","name":"Efel","postal_code":"69428","naf_code":"4619B"},{"siren":"751072919","name":"Jmp
111
+ Consulting","postal_code":"69120","naf_code":"4669C"},{"siren":"492543533","name":"Nang
112
+ Chop","postal_code":"69100","naf_code":"4711B"},{"siren":"453103731","name":"Rcte","postal_code":"69230","naf_code":"4321A"},{"siren":"404059701","name":"Ardom","postal_code":"69150","naf_code":"3320D"},{"siren":"389908831","name":"Maison
113
+ Tabbakh","postal_code":"69170","naf_code":"4721Z"},{"siren":"484613880","name":"La
114
+ Mie De Grigny","postal_code":"69520","naf_code":"1071B"},{"siren":"500034384","name":"Belle
115
+ Etoile Developpement","postal_code":"69370","naf_code":"6832B"},{"siren":"533820197","name":"Riso
116
+ Amaro","postal_code":"69006","naf_code":"5610A"},{"siren":"527813208","name":"A.S.A.P.","postal_code":"69007","naf_code":"4941A"},{"siren":"517734596","name":"Jacques
117
+ Chalvin Consultant","postal_code":"69570","naf_code":"6420Z"},{"siren":"481728202","name":"Consulting
118
+ Sport","postal_code":"69530","naf_code":"9319Z"},{"siren":"424233484","name":"Sofial
119
+ Rhone Alpes","postal_code":"69290","naf_code":"6920Z"},{"siren":"508539525","name":"Alpha
120
+ 8 Ingenierie","postal_code":"69740","naf_code":"7112B"},{"siren":"482928108","name":"Ambulance
121
+ De Gerland","postal_code":"69007","naf_code":"8690A"},{"siren":"490932381","name":"Calvy","postal_code":"69130","naf_code":"4643Z"},{"siren":"504197286","name":"Ap[Hi]","postal_code":"69002","naf_code":"7111Z"},{"siren":"523048296","name":"Apse","postal_code":"69600","naf_code":"4322A"},{"siren":"523934784","name":"Carrosserie
122
+ Martorana","postal_code":"69700","naf_code":"4520A"},{"siren":"499407542","name":"Abconsole","postal_code":"69003","naf_code":"4741Z"},{"siren":"450647722","name":"Cafe
123
+ Du Commerce","postal_code":"69003","naf_code":"5610A"},{"siren":"448166439","name":"Look
124
+ Immo","postal_code":"69008","naf_code":"7120B"},{"siren":"488093048","name":"Alarme
125
+ Technique Securite","postal_code":"69100","naf_code":"4321A"},{"siren":"491531265","name":"Flatot
126
+ Christophe Maconnerie","postal_code":"69220","naf_code":"4399C"},{"siren":"503779688","name":"Optima
127
+ Classe 6","postal_code":"69400","naf_code":"7022Z"},{"siren":"520954462","name":"Ag
128
+ Buro","postal_code":"69410","naf_code":"4799B"},{"siren":"530294826","name":"Caffé
129
+ Roma","postal_code":"69006","naf_code":"1082Z"},{"siren":"343938452","name":"Sarl
130
+ Neri","postal_code":"69150","naf_code":"9601A"},{"siren":"494156391","name":"Rebelle
131
+ Te''line","postal_code":"69008","naf_code":"4774Z"},{"siren":"305800013","name":"Ets
132
+ Contamin","postal_code":"69150","naf_code":"7010Z"},{"siren":"521344978","name":"M.A.L.T.","postal_code":"69290","naf_code":"6420Z"},{"siren":"502910276","name":"Pb
133
+ Invest","postal_code":"69700","naf_code":"6420Z"},{"siren":"421160656","name":"Island
134
+ Consulting \u0026 Investment","postal_code":"69630","naf_code":"6420Z"},{"siren":"493399968","name":"R.L.F.","postal_code":"69700","naf_code":"6420Z"},{"siren":"538813072","name":"Tremys","postal_code":"69004","naf_code":"6420Z"},{"siren":"318308699","name":"Societe
135
+ Commerciale Des Cassieres S.C.D.C.","postal_code":"69320","naf_code":"6420Z"},{"siren":"453123887","name":"Mc2
136
+ R","postal_code":"69970","naf_code":"4520A"},{"siren":"522202043","name":"I
137
+ Care","postal_code":"69270","naf_code":"7010Z"},{"siren":"492417589","name":"La
138
+ Gamme Beaujolaise","postal_code":"69460","naf_code":"4634Z"},{"siren":"521813725","name":"C
139
+ S A Centre Service Automobile","postal_code":"69380","naf_code":"4520A"},{"siren":"490533221","name":"A.M
140
+ Thermique","postal_code":"69440","naf_code":"4321A"},{"siren":"532363728","name":"Services
141
+ Sc Pronet","postal_code":"69960","naf_code":"8121Z"}]}}'
142
+ http_version:
143
+ recorded_at: Fri, 06 Jun 2014 15:55:14 GMT
144
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,134 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://firmapi.com/api/v1/companies?api_key=secret_api_key&page=2&postal_code=69
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - ! '*/*'
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: !binary |-
20
+ T0s=
21
+ headers:
22
+ !binary "U2VydmVy":
23
+ - !binary |-
24
+ bmdpbngvMS40LjEgKFVidW50dSk=
25
+ !binary "RGF0ZQ==":
26
+ - !binary |-
27
+ RnJpLCAwNiBKdW4gMjAxNCAxNjoxNDoxNyBHTVQ=
28
+ !binary "Q29udGVudC1UeXBl":
29
+ - !binary |-
30
+ YXBwbGljYXRpb24vanNvbjsgY2hhcnNldD11dGYtOA==
31
+ !binary "VHJhbnNmZXItRW5jb2Rpbmc=":
32
+ - !binary |-
33
+ Y2h1bmtlZA==
34
+ !binary "Q29ubmVjdGlvbg==":
35
+ - !binary |-
36
+ a2VlcC1hbGl2ZQ==
37
+ !binary "WC1GcmFtZS1PcHRpb25z":
38
+ - !binary |-
39
+ U0FNRU9SSUdJTg==
40
+ !binary "WC1Yc3MtUHJvdGVjdGlvbg==":
41
+ - !binary |-
42
+ MTsgbW9kZT1ibG9jaw==
43
+ !binary "WC1Db250ZW50LVR5cGUtT3B0aW9ucw==":
44
+ - !binary |-
45
+ bm9zbmlmZg==
46
+ !binary "RXRhZw==":
47
+ - !binary |-
48
+ IjQzOWU5N2IxMTBjZDMyNDU0NDAyODkwYzRmNzczMDVmIg==
49
+ !binary "Q2FjaGUtQ29udHJvbA==":
50
+ - !binary |-
51
+ bWF4LWFnZT0wLCBwcml2YXRlLCBtdXN0LXJldmFsaWRhdGU=
52
+ !binary "U2V0LUNvb2tpZQ==":
53
+ - !binary |-
54
+ cmVxdWVzdF9tZXRob2Q9R0VUOyBwYXRoPS8=
55
+ !binary "WC1SZXF1ZXN0LUlk":
56
+ - !binary |-
57
+ ODJmNWViNDgtZmVjYS00MjIzLWI4YTMtZmUwY2FlMTJkOGI4
58
+ !binary "WC1SdW50aW1l":
59
+ - !binary |-
60
+ MC4zNjU4NTc=
61
+ body:
62
+ encoding: UTF-8
63
+ string: ! '{"input":{"postal_code":"69","page":2},"result":{"search":{"results":103307,"size":100,"page":2,"number_of_pages":1033},"list":[{"siren":"424945756","name":"Ancestyle","postal_code":"69004","naf_code":"4775Z"},{"siren":"508897758","name":"Clb","postal_code":"69250","naf_code":"7022Z"},{"siren":"451866198","name":"Renuda","postal_code":"69220","naf_code":"7219Z"},{"siren":"488347865","name":"D.R.M.
64
+ Tec","postal_code":"69740","naf_code":"4669B"},{"siren":"445023419","name":"C.S.D.","postal_code":"69410","naf_code":"6202A"},{"siren":"409086261","name":"Gemnos","postal_code":"69009","naf_code":"7022Z"},{"siren":"453859043","name":"Société
65
+ Roche","postal_code":"69390","naf_code":"4399A"},{"siren":"488421348","name":"Alliance
66
+ Nouvelle","postal_code":"69100","naf_code":"4729Z"},{"siren":"483875217","name":"Bol
67
+ D''air","postal_code":"69570","naf_code":"5610A"},{"siren":"490769247","name":"Kéops
68
+ Emballages","postal_code":"69330","naf_code":"4676Z"},{"siren":"453231607","name":"Les
69
+ Iris","postal_code":"69500","naf_code":"5610A"},{"siren":"493425045","name":"Ferreol
70
+ David Sarl","postal_code":"69210","naf_code":"4391B"},{"siren":"452793177","name":"Ac
71
+ Distribution","postal_code":"69250","naf_code":"6190Z"},{"siren":"487672453","name":"Atelier
72
+ Du Tapissier","postal_code":"69220","naf_code":"9524Z"},{"siren":"493346514","name":"Delmar","postal_code":"69100","naf_code":"9602A"},{"siren":"522575554","name":"Cartaya","postal_code":"69006","naf_code":"6619B"},{"siren":"494398860","name":"Negoconseil","postal_code":"69400","naf_code":"7022Z"},{"siren":"529903445","name":"La
73
+ Forestelle","postal_code":"69870","naf_code":"5621Z"},{"siren":"479382939","name":"M.P.V.","postal_code":"69630","naf_code":"6420Z"},{"siren":"484016290","name":"Trokson","postal_code":"69001","naf_code":"5630Z"},{"siren":"399332964","name":"Le
74
+ Pere Penard","postal_code":"69005","naf_code":"4779Z"},{"siren":"419330188","name":"Gonzalez
75
+ Eyroulet","postal_code":"69780","naf_code":"4781Z"},{"siren":"340187350","name":"Chenil
76
+ Du Bois Seigneur","postal_code":"69210","naf_code":"0149Z"},{"siren":"531361079","name":"Je
77
+ Dis Vert","postal_code":"69360","naf_code":"8130Z"},{"siren":"492531207","name":"Ambiance
78
+ Coiffure","postal_code":"69480","naf_code":"9602A"},{"siren":"377956990","name":"Onyx","postal_code":"69100","naf_code":"6209Z"},{"siren":"505140574","name":"Pnm
79
+ Holding","postal_code":"69140","naf_code":"6420Z"},{"siren":"539388934","name":"Eurl
80
+ Bordemer","postal_code":"69960","naf_code":"8551Z"},{"siren":"514890078","name":"LAVERIE
81
+ DU 4 AOUT","postal_code":"69120","naf_code":"9601B"},{"siren":"515097277","name":"Jld
82
+ Concept","postal_code":"69400","naf_code":"6420Z"},{"siren":"444117709","name":"Serlica","postal_code":"69640","naf_code":"4941B"},{"siren":"751559147","name":"Transports
83
+ Diaz","postal_code":"69700","naf_code":"4941B"},{"siren":"433631330","name":"Les
84
+ Associes","postal_code":"69280","naf_code":"5610A"},{"siren":"509949053","name":"Acd
85
+ Consulting","postal_code":"69003","naf_code":"7022Z"},{"siren":"497568642","name":"CAFE
86
+ DES ALPES","postal_code":"69800","naf_code":"5610C"},{"siren":"438648339","name":"B
87
+ Pro Nett","postal_code":"69006","naf_code":"8121Z"},{"siren":"534931001","name":"Croq''point
88
+ Chaud","postal_code":"69400","naf_code":"5610C"},{"siren":"519419691","name":"Ns
89
+ Imm''self","postal_code":"69001","naf_code":"6831Z"},{"siren":"752693556","name":"Slcp","postal_code":"69530","naf_code":"7022Z"},{"siren":"507939569","name":"Val
90
+ D''ozon Transactions","postal_code":"69360","naf_code":"6831Z"},{"siren":"452039761","name":"A
91
+ Bee Institute","postal_code":"69100","naf_code":"4729Z"},{"siren":"529021636","name":"Starfactory","postal_code":"69260","naf_code":"7311Z"},{"siren":"519091722","name":"Aria
92
+ Conseil","postal_code":"69126","naf_code":"7022Z"},{"siren":"530497759","name":"LE
93
+ PRE FLEURI","postal_code":"69100","naf_code":"5610A"},{"siren":"352927610","name":"BILLARD
94
+ CHARLEMAGNE","postal_code":"69002","naf_code":"9329Z"},{"siren":"509084323","name":"NORISKO","postal_code":"69480","naf_code":"7120A"},{"siren":"482890027","name":"Lo
95
+ De Flo","postal_code":"69004","naf_code":"9602A"},{"siren":"750321887","name":"AUBERGE
96
+ DU PASTOUREAU","postal_code":"69690","naf_code":"5610A"},{"siren":"493837611","name":"Must
97
+ Pressing","postal_code":"69006","naf_code":"9601B"},{"siren":"450720842","name":"A.P.M.A.","postal_code":"69400","naf_code":"6920Z"},{"siren":"501048557","name":"Eurl
98
+ Rigaudier Carrosserie Des Grandes Terres","postal_code":"69650","naf_code":"4520A"},{"siren":"402132633","name":"Baraban","postal_code":"69003","naf_code":"6820A"},{"siren":"443529219","name":"Illiniza","postal_code":"69240","naf_code":"6420Z"},{"siren":"503627721","name":"Igene","postal_code":"69007","naf_code":"6420Z"},{"siren":"399003904","name":"F2
99
+ A","postal_code":"69008","naf_code":"4776Z"},{"siren":"505314641","name":"Cryo
100
+ Save France","postal_code":"69800","naf_code":"7219Z"},{"siren":"513180315","name":"E
101
+ Sens Sport","postal_code":"69126","naf_code":"9313Z"},{"siren":"421451071","name":"Restaurant
102
+ Bleu De France","postal_code":"69300","naf_code":"5610A"},{"siren":"489123612","name":"Saint
103
+ Victor Immobilier","postal_code":"69200","naf_code":"6831Z"},{"siren":"490713658","name":"Com\u0026Com","postal_code":"69006","naf_code":"6420Z"},{"siren":"422854216","name":"Century
104
+ 21 Immo Chazay","postal_code":"69380","naf_code":"6831Z"},{"siren":"530366467","name":"Batisab
105
+ Eurl","postal_code":"69120","naf_code":"4399D"},{"siren":"535266332","name":"Energy
106
+ Services Concept","postal_code":"69003","naf_code":"8299Z"},{"siren":"481631703","name":"Duguet
107
+ Toitures","postal_code":"69410","naf_code":"4391B"},{"siren":"438702086","name":"Investiplast","postal_code":"69120","naf_code":"6630Z"},{"siren":"498183854","name":"L''inattendu","postal_code":"69006","naf_code":"5610A"},{"siren":"528949670","name":"Galway
108
+ Conseils","postal_code":"69001","naf_code":"7022Z"},{"siren":"511325839","name":"Temps
109
+ D''avance","postal_code":"69360","naf_code":"6202A"},{"siren":"385217856","name":"Centre
110
+ De Controle Automobile De L''ouest","postal_code":"69290","naf_code":"7120A"},{"siren":"434142691","name":"G.L.I.","postal_code":"69006","naf_code":"6831Z"},{"siren":"530026640","name":"Zen
111
+ Erp Consulting","postal_code":"69009","naf_code":"6202A"},{"siren":"314369455","name":"Parfumerie
112
+ Zola","postal_code":"69002","naf_code":"4775Z"},{"siren":"530580778","name":"Vue
113
+ D''enfant","postal_code":"69006","naf_code":"4778A"},{"siren":"512542226","name":"Assurance
114
+ Immobilier Services","postal_code":"69002","naf_code":"6622Z"},{"siren":"484431366","name":"Heracles
115
+ Club","postal_code":"69400","naf_code":"9313Z"},{"siren":"334582426","name":"Betty
116
+ M","postal_code":"69250","naf_code":"4771Z"},{"siren":"479892549","name":"Mbg","postal_code":"69480","naf_code":"7022Z"},{"siren":"480776079","name":"Combotte
117
+ Immobilier","postal_code":"69400","naf_code":"6831Z"},{"siren":"479674186","name":"T.A.P.E.","postal_code":"69009","naf_code":"4642Z"},{"siren":"417807500","name":"Vignobles
118
+ Et Traditions","postal_code":"69640","naf_code":"4634Z"},{"siren":"323246652","name":"VICKY","postal_code":"69002","naf_code":"4771Z"},{"siren":"504370719","name":"Boticas","postal_code":"69100","naf_code":"4331Z"},{"siren":"524865417","name":"Pgis","postal_code":"69200","naf_code":"7112B"},{"siren":"414020206","name":"3
119
+ D Evolution","postal_code":"69200","naf_code":"8559A"},{"siren":"531362622","name":"Transports
120
+ Bost Luc","postal_code":"69240","naf_code":"4941A"},{"siren":"483167383","name":"Revello
121
+ Construction","postal_code":"69220","naf_code":"4399C"},{"siren":"509731444","name":"M2
122
+ P","postal_code":"69360","naf_code":"4329B"},{"siren":"439805904","name":"Gonzalez","postal_code":"69150","naf_code":"4334Z"},{"siren":"514142926","name":"Phr
123
+ Participations","postal_code":"69006","naf_code":"7010Z"},{"siren":"440147932","name":"Cabinet
124
+ Fargnoli Et Associes Societe D Expertise Comptable","postal_code":"69671","naf_code":"741C"},{"siren":"524591922","name":"B.A.M.A.A.","postal_code":"69002","naf_code":"7111Z"},{"siren":"477669253","name":"Alliance
125
+ Consulting","postal_code":"69410","naf_code":"7022Z"},{"siren":"483501839","name":"B
126
+ S H Barbotin Systemes Hydrauliques","postal_code":"69220","naf_code":"3312Z"},{"siren":"501842041","name":"Assurances
127
+ Baud Et Associes","postal_code":"69006","naf_code":"6622Z"},{"siren":"478839145","name":"Le
128
+ Terminal","postal_code":"69580","naf_code":"5610A"},{"siren":"499499630","name":"Melkhi","postal_code":"69300","naf_code":"6622Z"},{"siren":"751070244","name":"Boucherie
129
+ Chez Lionel","postal_code":"69100","naf_code":"4722Z"},{"siren":"400295820","name":"Casappa
130
+ S.A.R.L.","postal_code":"69003","naf_code":"2812Z"},{"siren":"301767372","name":"ERIG","postal_code":"69007","naf_code":"7111Z"},{"siren":"752490607","name":"Sedimo
131
+ Plomberie","postal_code":"69004","naf_code":"4322A"}]}}'
132
+ http_version:
133
+ recorded_at: Fri, 06 Jun 2014 16:14:18 GMT
134
+ recorded_with: VCR 2.9.2
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://firmapi.com/api/v1/company?api_key=123456&siren=INVALID%20SIREN
5
+ uri: https://firmapi.com/api/v1/company?api_key=secret_api_key&siren=INVALID%20SIREN
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://firmapi.com/api/v1/company?api_key=123456&siren=480470152
5
+ uri: https://firmapi.com/api/v1/company?api_key=secret_api_key&siren=480470152
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Firmapi::Company do
4
+
5
+ describe ":where" do
6
+
7
+ before(:each) do
8
+ VCR.use_cassette "find_companies_with_valid_siren" do
9
+ @companies = Firmapi::Companies.where(postal_code: 69)
10
+ end
11
+ end
12
+
13
+ subject(:companies) { @companies }
14
+
15
+ it { expect(subject.results).to eq 103307 }
16
+ it { expect(subject.size).to eq 100 }
17
+ it { expect(subject.page).to eq 1 }
18
+ it { expect(subject.number_of_pages).to eq 1033 }
19
+
20
+ context 'list' do
21
+
22
+ subject(:company) { @companies.to_a.first }
23
+
24
+ it { is_expected.to be_a Firmapi::Company }
25
+
26
+ it { expect(subject.name).to eq("C.M.") }
27
+ it { expect(subject.siren).to eq("527810279") }
28
+ it { expect(subject.nic).to be_nil }
29
+ it { expect(subject.commercial_name).to be_nil }
30
+
31
+ end
32
+
33
+ context ':next_page' do
34
+
35
+ before(:each) do
36
+ VCR.use_cassette "find_companies_with_valid_siren_next_page" do
37
+ @companies = @companies.next_page
38
+ end
39
+ end
40
+
41
+ subject(:companies) { @companies }
42
+
43
+ it { expect(subject.page).to eq 2 }
44
+
45
+ end
46
+
47
+ end
48
+
49
+ end
data/spec/company_spec.rb CHANGED
@@ -2,12 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe Firmapi::Company do
4
4
 
5
- before(:all) do
6
- Firmapi.configure do |config|
7
- config.api_key = "123456"
8
- end
9
- end
10
-
11
5
  describe ":find_by_siren!" do
12
6
 
13
7
  context 'with a valid siren' do
@@ -49,4 +43,5 @@ describe Firmapi::Company do
49
43
  end
50
44
 
51
45
  end
46
+
52
47
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'bundler/setup'
2
2
  require 'webmock/rspec'
3
- require 'VCR'
3
+ require 'vcr'
4
4
 
5
5
  require_relative '../lib/firmapi.rb'
6
6
 
@@ -8,4 +8,15 @@ VCR.configure do |c|
8
8
  c.cassette_library_dir = 'spec/cassettes'
9
9
  c.hook_into :webmock
10
10
  c.allow_http_connections_when_no_cassette = false
11
+ c.before_record do |i|
12
+ i.response.body.force_encoding('UTF-8')
13
+ end
14
+ end
15
+
16
+ RSpec.configure do |c|
17
+ c.before(:suite) do
18
+ Firmapi.configure do |config|
19
+ config.api_key = "secret_api_key"
20
+ end
21
+ end
11
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firmapi
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Etienne Depaulis
@@ -122,7 +122,7 @@ dependencies:
122
122
  - - ~>
123
123
  - !ruby/object:Gem::Version
124
124
  version: '1.0'
125
- description: Firmapi is a ruby client for www.firmapi.com
125
+ description: Firmapi is a ruby client for www.firmapi.com JSON API
126
126
  email:
127
127
  - etienne.depaulis@gmail.com
128
128
  executables: []
@@ -132,16 +132,22 @@ files:
132
132
  - .gitignore
133
133
  - .rspec
134
134
  - Gemfile
135
+ - Gemfile.lock
135
136
  - License.txt
136
137
  - README.md
137
138
  - Rakefile
138
139
  - firmapi.gemspec
139
140
  - lib/firmapi.rb
141
+ - lib/firmapi/api.rb
142
+ - lib/firmapi/companies.rb
140
143
  - lib/firmapi/company.rb
141
144
  - lib/firmapi/configuration.rb
142
145
  - lib/firmapi/version.rb
146
+ - spec/cassettes/find_companies_with_valid_siren.yml
147
+ - spec/cassettes/find_companies_with_valid_siren_next_page.yml
143
148
  - spec/cassettes/find_single_company_with_invalid_siren.yml
144
149
  - spec/cassettes/find_single_company_with_valid_siren.yml
150
+ - spec/companies_spec.rb
145
151
  - spec/company_spec.rb
146
152
  - spec/spec_helper.rb
147
153
  homepage: ''
@@ -167,10 +173,13 @@ rubyforge_project:
167
173
  rubygems_version: 2.0.14
168
174
  signing_key:
169
175
  specification_version: 4
170
- summary: Firmapi is a ruby client for www.firmapi.com
176
+ summary: Firmapi is a ruby client for www.firmapi.com JSON API
171
177
  test_files:
178
+ - spec/cassettes/find_companies_with_valid_siren.yml
179
+ - spec/cassettes/find_companies_with_valid_siren_next_page.yml
172
180
  - spec/cassettes/find_single_company_with_invalid_siren.yml
173
181
  - spec/cassettes/find_single_company_with_valid_siren.yml
182
+ - spec/companies_spec.rb
174
183
  - spec/company_spec.rb
175
184
  - spec/spec_helper.rb
176
185
  has_rdoc: