Module: ApiSabeqPsV1::SabeqHelpers
- Defined in:
- lib/api_sabeq_ps_v1/sabeq_helpers.rb
Constant Summary collapse
- REQUEST_HEADER =
{'Content-Type' => 'application/json'}
- SABEQ_URL =
"https://sabeq.ps"
Instance Method Summary collapse
- #sabeq_api_v1_1_create_parcel(verification_token, name, phone1, phone2, content, payment_amount, area_id, street_id, address, service_type, delivery_notes, special_notes) ⇒ Object
- #sabeq_api_v1_2_create_parcel(verification_token, name, phone1, phone2, content, payment_amount, area_id, street_id, address, location_url, service_type, delivery_notes, special_notes) ⇒ Object
-
#sabeq_api_v1_authorize(login_token) ⇒ Object
Authorize the request parameters: login_token return: true, auth_token in case of success false, errors in case of failure, errors contain code and message.
- #sabeq_api_v1_cancel_parcel(verification_token, parcel_number) ⇒ Object
- #sabeq_api_v1_create_parcel(verification_token, name, phone1, phone2, content, payment_amount, area_id, address, delivery_notes, special_notes) ⇒ Object
- #sabeq_api_v1_get_areas(verification_token) ⇒ Object
- #sabeq_api_v1_query_parcel(verification_token, parcel_number) ⇒ Object
-
#sabeq_api_v1_verify_profile(auth_token, profile_id, api_key) ⇒ Object
Verify the business profile.
Instance Method Details
#sabeq_api_v1_1_create_parcel(verification_token, name, phone1, phone2, content, payment_amount, area_id, street_id, address, service_type, delivery_notes, special_notes) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/api_sabeq_ps_v1/sabeq_helpers.rb', line 68 def sabeq_api_v1_1_create_parcel(verification_token, name, phone1, phone2, content, payment_amount, area_id, street_id, address, service_type, delivery_notes, special_notes) auth_link = SABEQ_URL + "/api/v1/parcels" auth_json = { verification_token: verification_token, name: name, phone1: phone1, phone2: phone2, content: content, payment_amount: payment_amount, area_id: area_id, street_id: street_id, address: address, service_type: service_type, delivery_notes: delivery_notes, special_notes: special_notes } json_response = make_post_request(auth_link, auth_json) return json_response end |
#sabeq_api_v1_2_create_parcel(verification_token, name, phone1, phone2, content, payment_amount, area_id, street_id, address, location_url, service_type, delivery_notes, special_notes) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/api_sabeq_ps_v1/sabeq_helpers.rb', line 84 def sabeq_api_v1_2_create_parcel(verification_token, name, phone1, phone2, content, payment_amount, area_id, street_id, address, location_url, service_type, delivery_notes, special_notes) auth_link = SABEQ_URL + "/api/v1/parcels" auth_json = { verification_token: verification_token, name: name, phone1: phone1, phone2: phone2, content: content, payment_amount: payment_amount, area_id: area_id, street_id: street_id, address: address, location_url: location_url, service_type: service_type, delivery_notes: delivery_notes, special_notes: special_notes } json_response = make_post_request(auth_link, auth_json) return json_response end |
#sabeq_api_v1_authorize(login_token) ⇒ Object
Authorize the request parameters: login_token return: true, auth_token in case of success
false, errors in case of failure, errors contain code and message
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/api_sabeq_ps_v1/sabeq_helpers.rb', line 13 def (login_token) auth_link = SABEQ_URL + "/api/v1/auth" auth_json = { login_token: login_token } json_response = make_post_request(auth_link, auth_json) result, the_response = get_error_or_returned_value(json_response) if result return true, the_response["auth_token"] else return false, the_response end end |
#sabeq_api_v1_cancel_parcel(verification_token, parcel_number) ⇒ Object
101 102 103 104 105 106 |
# File 'lib/api_sabeq_ps_v1/sabeq_helpers.rb', line 101 def sabeq_api_v1_cancel_parcel(verification_token, parcel_number) auth_link = SABEQ_URL + "/api/v1/parcels/#{parcel_number}/cancel_parcel" auth_json = { verification_token: verification_token } json_response = make_get_request(auth_link, auth_json) return json_response end |
#sabeq_api_v1_create_parcel(verification_token, name, phone1, phone2, content, payment_amount, area_id, address, delivery_notes, special_notes) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/api_sabeq_ps_v1/sabeq_helpers.rb', line 54 def sabeq_api_v1_create_parcel(verification_token, name, phone1, phone2, content, payment_amount, area_id, address, delivery_notes, special_notes) auth_link = SABEQ_URL + "/api/v1/parcels" auth_json = { verification_token: verification_token, name: name, phone1: phone1, phone2: phone2, content: content, payment_amount: payment_amount, area_id: area_id, address: address, delivery_notes: delivery_notes, special_notes: special_notes } json_response = make_post_request(auth_link, auth_json) return json_response end |
#sabeq_api_v1_get_areas(verification_token) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/api_sabeq_ps_v1/sabeq_helpers.rb', line 47 def sabeq_api_v1_get_areas(verification_token) auth_link = SABEQ_URL + "/api/v1/parcels/get_areas" auth_json = { verification_token: verification_token } json_response = make_get_request(auth_link, auth_json) return json_response end |
#sabeq_api_v1_query_parcel(verification_token, parcel_number) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/api_sabeq_ps_v1/sabeq_helpers.rb', line 40 def sabeq_api_v1_query_parcel(verification_token, parcel_number) auth_link = SABEQ_URL + "/api/v1/parcels/#{parcel_number}" auth_json = { verification_token: verification_token } json_response = make_get_request(auth_link, auth_json) return json_response end |
#sabeq_api_v1_verify_profile(auth_token, profile_id, api_key) ⇒ Object
Verify the business profile
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/api_sabeq_ps_v1/sabeq_helpers.rb', line 27 def sabeq_api_v1_verify_profile(auth_token, profile_id, api_key) auth_link = SABEQ_URL + "/api/v1/verify_business" auth_json = { auth_token: auth_token, profile_id: profile_id, api_key: api_key } json_response = make_post_request(auth_link, auth_json) result, the_response = get_error_or_returned_value(json_response) if result return true, the_response["verification_token"] else return false, the_response end end |