Module: DemoApi::SabeqHelpers
- Defined in:
- lib/demo_api/sabeq_helpers.rb
Constant Summary collapse
- REQUEST_HEADER =
- {'Content-Type' => 'application/json'} 
- SABEQ_URL =
          SABEQ_URL = “sabeq.ps” 
- "https://localhost:3001/"
Instance Method Summary collapse
- 
  
    
      #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. 
- #create_parcel(verification_token, name, phone1, phone2, content, payment_amount, area_id, address, delivery_notes) ⇒ Object
- #get_areas(verification_token) ⇒ Object
- #query_parcel(verification_token, parcel_number) ⇒ Object
- 
  
    
      #verify_profile(auth_token, profile_id, api_key)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Verify the business profile. 
Instance Method Details
#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
| 14 15 16 17 18 19 20 21 22 23 24 25 | # File 'lib/demo_api/sabeq_helpers.rb', line 14 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 | 
#create_parcel(verification_token, name, phone1, phone2, content, payment_amount, area_id, address, delivery_notes) ⇒ Object
| 55 56 57 58 59 60 61 62 63 64 65 66 | # File 'lib/demo_api/sabeq_helpers.rb', line 55 def create_parcel(verification_token, name, phone1, phone2, content, payment_amount, area_id, address, delivery_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 } json_response = make_post_request(auth_link, auth_json) return json_response end | 
#get_areas(verification_token) ⇒ Object
| 48 49 50 51 52 53 | # File 'lib/demo_api/sabeq_helpers.rb', line 48 def 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 | 
#query_parcel(verification_token, parcel_number) ⇒ Object
| 41 42 43 44 45 46 | # File 'lib/demo_api/sabeq_helpers.rb', line 41 def 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 | 
#verify_profile(auth_token, profile_id, api_key) ⇒ Object
Verify the business profile
| 28 29 30 31 32 33 34 35 36 37 38 39 | # File 'lib/demo_api/sabeq_helpers.rb', line 28 def 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 |