| POST | /cmd/locations |
|---|
# frozen_string_literal: true
# encoding: utf-8
require 'json'
require 'servicestack'
module DeviceUsageMode
CLERK_SERVICED = 0
PERSONAL = 1
SELF_SERVICE = 2
UNKNOWN = -1
end
module DeviceUserInterface
TABLET = 0
KIOSK = 1
DEFAULT = 2
UNKNOWN = -1
end
module DeviceManagement
PARTNER = 1
PLATFORM = 2
end
class Ref
include ServiceStack::DTO
# @return [String]
attr_accessor :id
# @return [String]
attr_accessor :val
def self.properties
{
id: { name: 'id' },
val: { name: 'val' },
}
end
end
class RefEx < Ref
# @return [RecordDictionary]
attr_accessor :data
def self.properties
{
data: { name: 'data', type: RecordDictionary },
}
end
end
class GPSCoordinates
include ServiceStack::DTO
# @return [Float]
attr_accessor :lat
# @return [Float]
attr_accessor :lng
def self.properties
{
lat: { name: 'lat' },
lng: { name: 'lng' },
}
end
end
class Address
include ServiceStack::DTO
# @return [String]
attr_accessor :street
# @return [String]
attr_accessor :city
# @return [String]
attr_accessor :state
# @return [String]
attr_accessor :postal_code
# @return [Ref]
attr_accessor :country
# @return [GPSCoordinates]
attr_accessor :gps
# @return [RecordDictionary]
attr_accessor :data
def self.properties
{
street: { name: 'street' },
city: { name: 'city' },
state: { name: 'state' },
postal_code: { name: 'postalCode' },
country: { name: 'country', type: Ref },
gps: { name: 'gps', type: GPSCoordinates },
data: { name: 'data', type: RecordDictionary },
}
end
end
class DeviceProfile
include ServiceStack::DTO
# @return [DeviceUsageMode]
attr_accessor :usage_mode
# @return [DeviceUserInterface]
attr_accessor :user_interface
# @return [Ref]
attr_accessor :wallet
# @return [DeviceManagement]
attr_accessor :managed_by
def self.properties
{
usage_mode: { name: 'usageMode' },
user_interface: { name: 'userInterface' },
wallet: { name: 'wallet', type: Ref },
managed_by: { name: 'managedBy' },
}
end
end
class Device
include ServiceStack::DTO
# @return [String]
attr_accessor :id
# @return [String]
attr_accessor :name
# @return [TrueClass]
attr_accessor :is_active
# @return [DeviceProfile]
attr_accessor :profile
# @return [RecordDictionary]
attr_accessor :integrations_data
def self.properties
{
id: { name: 'id' },
name: { name: 'name' },
is_active: { name: 'isActive' },
profile: { name: 'profile', type: DeviceProfile },
integrations_data: { name: 'integrationsData', type: RecordDictionary },
}
end
end
class ProductReference
include ServiceStack::DTO
# @return [String]
attr_accessor :id
# @return [String]
attr_accessor :value
# @return [String]
attr_accessor :category
# @return [Ref]
attr_accessor :product_provider
def self.properties
{
id: { name: 'id' },
value: { name: 'value' },
category: { name: 'category' },
product_provider: { name: 'productProvider', type: Ref },
}
end
end
class ProductInstanceRef
include ServiceStack::DTO
# @return [String]
attr_accessor :id
# @return [String]
attr_accessor :name
# @return [String]
attr_accessor :title
# @return [ProductReference]
attr_accessor :product
def self.properties
{
id: { name: 'id' },
name: { name: 'name' },
title: { name: 'title' },
product: { name: 'product', type: ProductReference },
}
end
end
class Locale
include ServiceStack::DTO
# @return [Ref]
attr_accessor :time_zone
# @return [Ref]
attr_accessor :currency
# @return [Ref]
attr_accessor :language
def self.properties
{
time_zone: { name: 'timeZone', type: Ref },
currency: { name: 'currency', type: Ref },
language: { name: 'language', type: Ref },
}
end
end
class OpenLocation
include ServiceStack::DTO
# @return [String]
attr_accessor :id
# @return [String]
attr_accessor :name
# @return [RefEx]
attr_accessor :organization
# @return [Ref]
attr_accessor :region
# @return [Ref]
attr_accessor :group
# @return [Address]
attr_accessor :address
# @return [List]
attr_accessor :devices
# @return [List]
attr_accessor :product_instances
# @return [Locale]
attr_accessor :locale
# @return [Dictionary]
attr_accessor :integrations_data
def self.properties
{
id: { name: 'id' },
name: { name: 'name' },
organization: { name: 'organization', type: RefEx },
region: { name: 'region', type: Ref },
group: { name: 'group', type: Ref },
address: { name: 'address', type: Address },
devices: { name: 'devices', type: [Device] },
product_instances: { name: 'productInstances', type: [ProductInstanceRef] },
locale: { name: 'locale', type: Locale },
integrations_data: { name: 'integrationsData' },
}
end
def response_type() = ServiceStack::ResponseStatus
def get_type_name() = 'OpenLocation'
end
class RecordDictionary < Hash
end
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /cmd/locations HTTP/1.1
Host: api.bettor.webhop.biz
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
id: String,
name: String,
organization:
{
data:
{
String: String
},
id: String,
val: String
},
region:
{
id: String,
val: String
},
group:
{
id: String,
val: String
},
address:
{
street: String,
city: String,
state: String,
postalCode: String,
country:
{
id: String,
val: String
},
gps:
{
lat: 0,
lng: 0
},
data:
{
String: String
}
},
devices:
[
{
id: String,
name: String,
isActive: False,
profile:
{
usageMode: 0,
userInterface: 0,
wallet:
{
id: String,
val: String
},
managedBy: 0
},
integrationsData:
{
String: String
}
}
],
productInstances:
[
{
id: String,
name: String,
title: String,
product:
{
id: String,
value: String,
category: String,
productProvider:
{
id: String,
val: String
}
}
}
],
locale:
{
timeZone:
{
id: String,
val: String
},
currency:
{
id: String,
val: String
},
language:
{
id: String,
val: String
}
},
integrationsData:
{
String: String
}
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
errorCode: String,
message: String,
stackTrace: String,
errors:
[
{
errorCode: String,
fieldName: String,
message: String,
meta:
{
String: String
}
}
],
meta:
{
String: String
}
}