| POST | /cmd/organizations |
|---|
# frozen_string_literal: true
# encoding: utf-8
require 'json'
require 'servicestack'
module OrganizationNature
FIRST_PARTY = 1
PARTNER = 2
end
module WalletPayoutMode
REAL_TIME = 0
BATCH_PAYOUT = 1
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 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 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 WinningsExpirationPolicy
include ServiceStack::DTO
# @return [TrueClass]
attr_accessor :enabled
# @return [Time]
attr_accessor :interval
def self.properties
{
enabled: { name: 'enabled' },
interval: { name: 'interval' },
}
end
end
class IntegrationConnection
include ServiceStack::DTO
# @return [String]
attr_accessor :url
# @return [String]
attr_accessor :credentials_ref
def self.properties
{
url: { name: 'url' },
credentials_ref: { name: 'credentialsRef' },
}
end
end
class IntegrationInstance
include ServiceStack::DTO
# @return [String]
attr_accessor :id
# @return [String]
attr_accessor :integration_id
# @return [IntegrationConnection]
attr_accessor :wallet
# @return [IntegrationConnection]
attr_accessor :partner_api
# @return [TrueClass]
attr_accessor :slip_forwarding_enabled
def self.properties
{
id: { name: 'id' },
integration_id: { name: 'integrationId' },
wallet: { name: 'wallet', type: IntegrationConnection },
partner_api: { name: 'partnerApi', type: IntegrationConnection },
slip_forwarding_enabled: { name: 'slipForwardingEnabled' },
}
end
end
class OrganizationIntegrations
include ServiceStack::DTO
# @return [IntegrationInstance]
attr_accessor :first_party
# @return [IntegrationInstance]
attr_accessor :partner
def self.properties
{
first_party: { name: 'firstParty', type: IntegrationInstance },
partner: { name: 'partner', type: IntegrationInstance },
}
end
end
class PayoutPolicy
include ServiceStack::DTO
# @return [WalletPayoutMode]
attr_accessor :self_service
# @return [WalletPayoutMode]
attr_accessor :personal
def self.properties
{
self_service: { name: 'selfService' },
personal: { name: 'personal' },
}
end
end
class RegisterOrganization
include ServiceStack::DTO
# @return [String]
attr_accessor :id
# @return [String]
attr_accessor :name
# @return [Address]
attr_accessor :address
# @return [Locale]
attr_accessor :locale
# @return [RecordDictionary]
attr_accessor :integrations_data
# @return [WinningsExpirationPolicy]
attr_accessor :winnings_expiration_policy
# @return [OrganizationNature]
attr_accessor :nature
# @return [OrganizationIntegrations]
attr_accessor :integrations
# @return [PayoutPolicy]
attr_accessor :payout_policy
def self.properties
{
id: { name: 'id' },
name: { name: 'name' },
address: { name: 'address', type: Address },
locale: { name: 'locale', type: Locale },
integrations_data: { name: 'integrationsData', type: RecordDictionary },
winnings_expiration_policy: { name: 'winningsExpirationPolicy', type: WinningsExpirationPolicy },
nature: { name: 'nature' },
integrations: { name: 'integrations', type: OrganizationIntegrations },
payout_policy: { name: 'payoutPolicy', type: PayoutPolicy },
}
end
def response_type() = ServiceStack::ResponseStatus
def get_type_name() = 'RegisterOrganization'
end
class RecordDictionary < Hash
end
Ruby RegisterOrganization DTOs
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/organizations HTTP/1.1
Host: api.bettor.webhop.biz
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
id: String,
name: String,
address:
{
street: String,
city: String,
state: String,
postalCode: String,
country:
{
id: String,
val: String
},
gps:
{
lat: 0,
lng: 0
},
data:
{
String: String
}
},
locale:
{
timeZone:
{
id: String,
val: String
},
currency:
{
id: String,
val: String
},
language:
{
id: String,
val: String
}
},
integrationsData:
{
String: String
},
winningsExpirationPolicy:
{
enabled: False,
interval: PT0S
},
nature: 0,
integrations:
{
firstParty:
{
id: String,
integrationId: String,
wallet:
{
url: String,
credentialsRef: String
},
partnerApi:
{
url: String,
credentialsRef: String
},
slipForwardingEnabled: False
},
partner:
{
id: String,
integrationId: String,
wallet:
{
url: String,
credentialsRef: String
},
partnerApi:
{
url: String,
credentialsRef: String
},
slipForwardingEnabled: False
}
},
payoutPolicy:
{
selfService: 0,
personal: 0
}
}
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
}
}