demo_api 0.1.3 → 0.1.4

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
  SHA256:
3
- metadata.gz: f691b8661c00573c9ddf86a725d26562261ba6aab8cb58b49ba6105c94f1c9f7
4
- data.tar.gz: 2aaa64cb54e69fd77c667f2646bedcd53578398f1b673a76e3b2101a619ca98d
3
+ metadata.gz: f8d020c180eee5b2934657cace1ac5915589ec0f49b8d651555b5d4b25d5716b
4
+ data.tar.gz: 6cbef2ebc1ca75003f692cd74652bbd7214375d6ec700aa83106d22d2be1219e
5
5
  SHA512:
6
- metadata.gz: 6235b1f5018c64631319a6bef61d0d149f48879c4a4b2c41acea22438f9f19cff811d62852712bcf969babe9c6235e76036f2cb80b0331ba5fd155f149207006
7
- data.tar.gz: c84c1ecba11beb26aebe82d8d61e556cf43ebfa3788e5eb7750cbe020e9c29f88330be8c37f6f4fc7d7d614158b129ce8db7e45acaec7123c119ad0aa88612e1
6
+ metadata.gz: b34ad7e69d6665d126057276db88467d1bf302db865efe62cc4156b7ab97eff9e7b82999821683141241ea63ac148b613427817a33c5138288a901170f609ca5
7
+ data.tar.gz: f3e418969dab3991b1a23e6be13388e64974952d63f8d87431728225a4d3a3fb2bb031c091b49992952060ec3020e231ea9f343665aa563f475ad229f93072bc
data/lib/demo_api.rb CHANGED
@@ -31,7 +31,6 @@ module DemoApi
31
31
 
32
32
  # Verify the business profile
33
33
  def verify_profile(auth_token, profile_id, api_key)
34
- puts '33333333333333'
35
34
  auth_link = SABEQ_URL + "/api/v1/verify_business"
36
35
  auth_json = { auth_token: auth_token, profile_id: profile_id, api_key: api_key }
37
36
  json_response = make_post_request(auth_link, auth_json)
@@ -44,6 +43,13 @@ module DemoApi
44
43
  end
45
44
  end
46
45
 
46
+ def query_parcel(verification_token, parcel_number)
47
+ auth_link = SABEQ_URL + "/api/v1/parcels/#{parcel_number}"
48
+ auth_json = { verification_token: verification_token }
49
+ json_response = make_get_request(auth_link, auth_json)
50
+ return json_response
51
+ end
52
+
47
53
  private
48
54
  def make_post_request(url_link, json_content)
49
55
  uri = URI.parse(url_link)
@@ -52,8 +58,17 @@ module DemoApi
52
58
  a_request = Net::HTTP::Post.new(uri.request_uri, REQUEST_HEADER)
53
59
  a_request.body = json_content.to_json
54
60
  a_response = http.request(a_request)
55
- puts '4444444444444'
56
- puts a_response.body
61
+ return a_response.body
62
+ end
63
+
64
+ def make_get_request(url_link, json_content)
65
+ uri = URI.parse(url_link)
66
+ http = Net::HTTP.new(uri.host, uri.port)
67
+ http.use_ssl = false
68
+ the_params = json_content
69
+ uri.query = URI.encode_www_form(the_params)
70
+ a_request = Net::HTTP::Get.new(uri.request_uri)
71
+ a_response = http.request(a_request)
57
72
  return a_response.body
58
73
  end
59
74
 
@@ -1,3 +1,3 @@
1
1
  module DemoApi
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: demo_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ShaimaKaraki