Class: PostCL::API

Inherits:
Object
  • Object
show all
Defined in:
lib/postcl/api.rb

Defined Under Namespace

Classes: InvalidRequestError, Response

Class Method Summary collapse

Class Method Details

.API_URIObject



5
6
7
# File 'lib/postcl/api.rb', line 5

def self.API_URI
  "https://jouw.postnl.nl/web/api/default/shipmentStatus/"
end

.request(b_code, p_code) ⇒ Object



9
10
11
12
13
14
# File 'lib/postcl/api.rb', line 9

def self.request(b_code, p_code)
  r = HTTParty.get(self.API_URI + b_code + "-NL-" + p_code, format: :plain)
  raise InvalidRequestError if r.code != 200
  stat_dict = JSON.parse r.body, symbolize_names: true
  PostCL::API::Response.new(stat_dict)
end