Rangana
277
6
Laravel

API Integration

Posted 1 month ago by Rangana

I need to integrate the following API questing using Laravel. how can I do this

We would like you to make a connection to the mentioned API using below details and retrieve some data/information. Please see below process.
1. create a simple php class to communicate with the api with the following functions
1. get
1. table
2. page
2. search
1. table
2. query
3. update
1. id
2. table
3. data
2. Should be able to pass any tablename but will only be required to access product and taxrate (so table name is either “product” or “tax”)
3. Fetch a list of all products using the class
4. Convert the products into a paginated table using divs instead of <table> (use html, php and css)
I. Sort the products alphabetically
II. Max 20 products per page
III. Headings
a. ID
b. Name
c. Cost Price
d. Sale Price
IV. Will need to be paginated so can easily browse to e.g page 5
V. Find the product ID for ‘WrightWay Example’ using the table and display details on screen.
5. Change the product “WrightWay Example” to 'WrightWay'
You can use any method you see fit to achieve above.
We prefer to have a simple user interface for all functions above mentioned. As an example to retrieve all products you can use a button named “Get all products”.
See next page for API details….
API Access Details and relevant documentation:
Epos Key (Access key for calls into API ) : F50368501B084C26A480A7F728E4169E
Epos Secret (Password for calls into API ) : E72E8F14846445248890038867E3FB03
To access the API, simply pass an Authorization header with your request, containing Basic and your API access token.
Example Authorization header to be sent with your request:
Authorization: Basic API_ACCESS_TOKEN
You will also need to pass a Content-type header (e.g. application/json) to specify the response data type.
To obtain your API_ACCESS_TOKEN please concatenate your API Key, a colon character ":", and you API Secret in to single string (no spaces) and then Base64 encode it.
API_ACCESS_TOKEN = base64encode(Epos Key:Epos Secret)
GET HTTP://api.eposnowhq.com/api/V1/product/1
{
Authorization: Basic INSERT_API_ACCESS_TOKEN
Content-type: application/json
}
Retrieve Product Details To retrieve an existing Product list, send the request:
GET https://api.eposnowhq.com/api/V2/Product/
Response:
...
List of the first 200 Products
You can retrieve more Products by specifying a page number:
GET https://api.eposnowhq.com/api/V2/Product?page={Page_No}
To retrieve a specific Product by ID
https://api.eposnowhq.com/api/V2/Product/{Product_ID}
REQUEST:
GET HTTPS://API.EposnowHQ.com/API/V2/Product/
{
Authorization : Basic INSERT_API_ACCESS_TOKEN
}
RESPONSE:
HTTP/1.1 200 OK
{
ProductID: 6,
Name: "Green Tea",
Description: null,
CostPrice: 0.3,
SalePrice: 1.5,
EatOutPrice: 0,
CategoryID: null,
Barcode: null,
TaxRateID: 33,
EatOutTaxRateID: null,
BrandID: null,
SupplierID: null,
PopupNoteID: null,
UnitOfSale: null,
VolumeOfSale: null,
MultiChoiceID: null,
ColourID: null,
VariantGroupID: null,
Size: null,
Sku: null,
SellOnWeb: false,
SellOnTill: true,
OrderCode: null,
ButtonColourID: null,
SortPosition: null,
MagentoAttributeSetID: null,
RRPrice: null,
CostPriceTaxRateID: null,
ProductType: 0,
TareWeight: null,
ArticleCode: null
}
Update Products Details
The parameter(s) of a particular Product can be updated by supplying the ProductID and parameter(s) in a PUT/PATCH request
PUT/PATCH https://api.eposnowhq.com/api/V2/Product/{Product_ID}
Search for a Item by specific property value
To retrieve one or more specific Item, use:
GET https://api.eposnowhq.com/api/V2/{ItemName}?{PropertyName}={Value}
Url params
{ItemName}
Item Name: e.g. Customer,Product
{PropertyName}
Property Name: e.g. Name,Description
{Value}
Property Value: e.g. Smith,Tea
Search for the Items by property value or range
The API V2 allows you to search for a specific value or range of properties
Allowed Queries
like, contains
GET https://api.eposnowhq.com/api/V2/{ItemName}?search=(propertyName|like|value) GET https://api.eposnowhq.com/api/V2/{ItemName}?search=(propertyName|contains|value)
>
GET https://api.eposnowhq.com/api/V2/{ItemName}?search=(propertyName|>|value)
>=
GET https://api.eposnowhq.com/api/V2/{ItemName}?search=(propertyName|>=|value)
<
GET https://api.eposnowhq.com/api/V2/{ItemName}?search=(propertyName|<|value)
<=
GET https://api.eposnowhq.com/api/V2/{ItemName}?search=(propertyName|<=|value)
EndsWith
GET https://api.eposnowhq.com/api/V2/{ItemName}?search=(propertyName|EndsWith|value)
StartsWith
GET https://api.eposnowhq.com/api/V2/{ItemName}?search=(propertyName|StartsWith|value)
Order results by property value
To order your results ascendingly by a specific property, use:
https://api.eposnowhq.com/api/V2/{ItemName}?OrderBy={Property_Name

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.