Wiki

Grainit webservice documentation

1. Validate integration

Input Type Description Example Required/optional
partner_id_hash String Partner api key 123456aaaabas Required
customer_number String Users customer_number 112233 Required
vat_number String Users vat_number 1253451 Required

The information should be sent to:

https://portal.grainit.net/webservice/webservice.php?action=validate_integration using a POST


Example

partner_id_hash: 123456aaaabas

customer_number: 112233

vat_number: 1253451

would look like this when sent:

&partner_id_hash=123456aaaabas&customer_number=112233&vat_number=1253451


Return data

We always return a json string

When the call is successful it will look like this: {"error":"0","data":{"status":"1","customer_hash":"213a54d3z54354d354z"}}

When an error is encountered it will look something like this: {"error":"1","errormsg":"Integration not found"}

The key is always present, so that can be used to tell if an error was encountered

If an error was encountered, then the key errormsg will explain what went wrong


2. Add data from external partner

Input Type Description Example Required/optional Live/Dev
type String Can be purchase, sale, or storage. Only purchase is supported at the moment purchase Required Both
customer_hash String This is the hash string that was returned when the user was verified against the validation webservice 2340sdjh9ksjdhf (real string is longer) Required Both
date String This should either be a unix_timestamp or an UTC datetime string in the format YYYY-mm-dd HH:ii:ss 1467193208 Or 2016-06-29 09:40:08 Required Both
item_number String If the string has never been sent to the webservice before, for this customer, then the item_text, and item_type will be used to create the product 12345 Required Both
item_text String A string that describes the product Barley Required Both
item_type String A string that describes if the product is grain or raw_product raw_product Optional Both
delivery_address_id String A unique string that describes the sent delivery address, this is the key to making sure that the product is always placed in the correct location 1 Required Both
delivery_address_name String Name John Farmer Required Both
delivery_address_address String Address Farm road 1 Required Both
delivery_address_silo_ident String Silo 3 Optional Both
delivery_address_zip String Zip 1234 Required Both
delivery_address_city String City Farmer city Required Both
unit String What unit the data is passed as. Default is kg. pcs/kg Optional Dev
weight Int The total weight in kg or number of pcs of the product 10000 Required Live
(Pcs on Dev)
water_percentage Double The water percentage in the product 14.2 Optional Both
total_price Double The total price of this transanction 123.12 Optional Both
price_currency String ISO 4217 currency code, DKK, EUR, etc. DKK Optional (required if total_price is used) Both
document_number String A unique string that describes this exact transaction ABC123 Optional Both
maingroup_id Int A unique number that describes the main group the product is belonging to 101 Required Dev
maingroup_text String A unique string that describes the main group name ABC123 Required Dev
subgroup_id Int A unique number that describes the sub group the product is belonging to 140 Optional Dev
subgroup_text String A unique string that describes the sub group name ABC123 Optional Dev

Data should always be utf8 encoded

The information should be sent to:

https://portal.grainit.net/webservice/webservice.php?action=add_registration_from_external_partner using a POST


Example

type: purchase

customer_hash: 2340sdjh9ksjdhf

date: 2016-06-29 09:40:08

item_number: 12345

item_text: Barley

item_type: raw_product

delivery_address_id: 1

delivery_address_name: John Farmer

delivery_address_address: Farm road 1

delivery_address_silo_ident: 3

delivery_address_city: Farmer city

weight: 10000

water_percentage: 14.2

total_price: 123.12

price_currency: DKK

document_number: ABC123

would look like this when sent:

&type=purchase&customer_hash=2340sdjh9ksjdhf&date=2016-06-29+09 %3A40%3A08&item_number=12345&item_text=Barley&item_type=raw_product&delivery_address_id=1
&delivery_address_name=John+Farmer&delivery_address_address=Farm+road+1&delivery_address_silo_ident=3&delivery_address_city=Farmer+city&weight=10000
&water_percentage=14.2&total_price=123.12&price_currency=DKK&document_number=ABC123


Return data

We always return a json string

When the call is successful it will look like this: {"error":"0","data":{"status":"1"}}

When an error is encountered it will look something like this: {"error":"1","errormsg":"Integration not found"}

The error key is always present, so that can be used to tell if an error was encountered

If an error was encountered, then the key errormsg will explain what went wrong


Last updated: 17. February 2017

OK