Class: Be::Data::Api
- Inherits:
-
Object
- Object
- Be::Data::Api
- Defined in:
- lib/be-data-api.rb,
lib/be-data-api/version.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Method Summary collapse
-
#initialize(api_id, api_key) ⇒ Api
constructor
A new instance of Api.
-
#vat_basic(vat_number) ⇒ Object
API DOC: api.data.be/#basic.
-
#vat_status(vat_number) ⇒ Object
API DOC: api.data.be/#status.
-
#vat_valid?(vat_number) ⇒ Boolean
API DOC: api.data.be/#validity.
Constructor Details
#initialize(api_id, api_key) ⇒ Api
Returns a new instance of Api.
9 10 11 |
# File 'lib/be-data-api.rb', line 9 def initialize(api_id, api_key) @conn = Excon.new("https://api.data.be", :query => { "api_id" => api_id, "api_key" => api_key }) end |
Instance Method Details
#vat_basic(vat_number) ⇒ Object
API DOC: api.data.be/#basic
40 41 42 43 44 45 |
# File 'lib/be-data-api.rb', line 40 def vat_basic(vat_number) response = get("/1.0/vat/#{vat_number}/basic") return VatBasic.new(response['vat-clean'], response['vat-formatted'], !!response['active'], !!response['valid'], response['company-name'], response['start-date'], response['language'], response['address-fr'], response['address-nl']) end |
#vat_status(vat_number) ⇒ Object
API DOC: api.data.be/#status
29 30 31 32 |
# File 'lib/be-data-api.rb', line 29 def vat_status(vat_number) response = get("/1.0/vat/#{vat_number}/status") return VatStatus.new(response['vat-clean'], response['vat-formatted'], !!response['active'], !!response['valid']) end |
#vat_valid?(vat_number) ⇒ Boolean
API DOC: api.data.be/#validity
18 19 20 21 22 |
# File 'lib/be-data-api.rb', line 18 def vat_valid?(vat_number) response = get("/1.0/vat/#{vat_number}/validity") p response return !!response["valid"] end |