api_demo_v1 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e4f389def95022e4edddd9579ec1330d6835344093621042a7c169ae0858751
4
- data.tar.gz: 00a1fb4734d2a0764cee4b1ddcf65c4e6a0552176b13827cf834504871e0ea49
3
+ metadata.gz: bf2c86acfc69735a4d1deea17e567f414a79734b35b18230816a055f8d048fa5
4
+ data.tar.gz: 2aa2f10237940946ecd54632c08e448606082f767934cd87a9e091436e1633eb
5
5
  SHA512:
6
- metadata.gz: 8bcf299256aaf9b879eb718cc2c6fab09843f2f39128aa12bd392a11641b3cb08eca5f556963d020ccd62c51ea9f38badd1eab33259315a07f50cbb298bf2236
7
- data.tar.gz: 1825d522e993aa9ebf4783073c7671cc6237448d4df6d7f9e2903a0c99b41c92598690a04ad8659a34d2bdd7b1fded03d8250d875f86a360d974365319b18624
6
+ metadata.gz: d1aa6850ca6f68e919b5b602c1a137467d54e31913501b1924a5cf568aebf7973a284b18c796a46020609505f1e21ecb9c69c4cb463b795de0a2780439b66df1
7
+ data.tar.gz: 7e08d75caaf2d81a71ef99c4876197f9bfbf98cbc96d53281aa33bf737678b71658c6d15980bda21d959fd8aabb04537916179729e1ccb045c7556bc997f2c28
@@ -4,7 +4,7 @@ require "net/https"
4
4
  module ApiDemoV1
5
5
  module SabeqHelpers
6
6
  REQUEST_HEADER = {'Content-Type' => 'application/json'}
7
- SABEQ_URL = "https://localhost:3001/"
7
+ SABEQ_URL = "http://localhost:3000/"
8
8
 
9
9
  # Authorize the request
10
10
  # parameters: login_token
@@ -44,6 +44,27 @@ module ApiDemoV1
44
44
  return json_response
45
45
  end
46
46
 
47
+ def sabeq_api_v1_print_parcel(verification_token, parcel_number, the_size = "default")
48
+ url = SABEQ_URL + "/api/v1/parcels/#{parcel_number}/print"
49
+
50
+ params = {
51
+ verification_token: verification_token,
52
+ size: the_size
53
+ }
54
+
55
+ uri = URI.parse(url)
56
+ uri.query = URI.encode_www_form(params)
57
+
58
+ http = Net::HTTP.new(uri.host, uri.port)
59
+ http.use_ssl = false
60
+
61
+ request = Net::HTTP::Get.new(uri.request_uri)
62
+ response = http.request(request)
63
+
64
+ # IMPORTANT: return raw HTML, not JSON parsing
65
+ response.body
66
+ end
67
+
47
68
  def sabeq_api_v1_get_areas(verification_token)
48
69
  auth_link = SABEQ_URL + "/api/v1/parcels/get_areas"
49
70
  auth_json = { verification_token: verification_token }
@@ -98,6 +119,22 @@ module ApiDemoV1
98
119
  return json_response
99
120
  end
100
121
 
122
+ def sabeq_api_v1_update_parcel(verification_token, parcel_number, collect_money, name, phone1, phone2, content, address, area_id, street_id)
123
+ auth_link = SABEQ_URL + "/api/v1/parcels/#{parcel_number}"
124
+ auth_json = { verification_token: verification_token,
125
+ payment_amount: collect_money,
126
+ customer_name: name,
127
+ phone1: phone1,
128
+ phone2: phone2,
129
+ content: content,
130
+ address: address,
131
+ area_id: area_id,
132
+ street_id: street_id}
133
+ json_response = make_patch_request(auth_link, auth_json)
134
+
135
+ return json_response
136
+ end
137
+
101
138
  def sabeq_api_v1_cancel_parcel(verification_token, parcel_number)
102
139
  auth_link = SABEQ_URL + "/api/v1/parcels/#{parcel_number}/cancel_parcel"
103
140
  auth_json = { verification_token: verification_token }
@@ -127,6 +164,16 @@ module ApiDemoV1
127
164
  return a_response.body
128
165
  end
129
166
 
167
+ def make_patch_request(url_link, json_content)
168
+ uri = URI.parse(url_link)
169
+ http = Net::HTTP.new(uri.host, uri.port)
170
+ http.use_ssl = false
171
+ a_request = Net::HTTP::Patch.new(uri.request_uri, REQUEST_HEADER)
172
+ a_request.body = json_content.to_json
173
+ a_response = http.request(a_request)
174
+ return a_response.body
175
+ end
176
+
130
177
  def get_error_or_returned_value(json_response)
131
178
  # check if the response has errors
132
179
  hashed_response = JSON.parse(json_response)
@@ -1,3 +1,3 @@
1
1
  module ApiDemoV1
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_demo_v1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - ShaimaKaraki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-09 00:00:00.000000000 Z
11
+ date: 2026-04-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Its a gem for sabeq.ps API helper functionalities
14
14
  email:
@@ -21,7 +21,7 @@ files:
21
21
  - lib/api_demo_v1/railtie.rb
22
22
  - lib/api_demo_v1/sabeq_helpers.rb
23
23
  - lib/api_demo_v1/version.rb
24
- homepage: https://github.com/ShaimaKaraki/s_api.git
24
+ homepage: https://github.com/ShaimaKaraki/api_demo_v1.git
25
25
  licenses:
26
26
  - MIT
27
27
  metadata: {}
@@ -40,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  requirements: []
43
- rubygems_version: 3.3.7
43
+ rubygems_version: 3.5.16
44
44
  signing_key:
45
45
  specification_version: 4
46
46
  summary: gem for sabeq.ps API helper functionalities