MyApp

<back to all web services

CreatePlayer

Game
# frozen_string_literal: true
# encoding: utf-8


require 'json'
require 'servicestack'


module PhoneKind
    HOME = 'Home'
    MOBILE = 'Mobile'
    WORK = 'Work'
end

class Phone
    include ServiceStack::DTO

    # @return [PhoneKind]
    attr_accessor :kind
    # @return [String]
    attr_accessor :number
    # @return [String]
    attr_accessor :ext

    def self.properties
        {
            kind: { name: 'kind' },
            number: { name: 'number' },
            ext: { name: 'ext' },
        }
    end

end

class CreatePlayer
    include ServiceStack::DTO

    # @Validate(Validator: "NotEmpty")
    # @return [String]
    attr_accessor :first_name

    # @return [String]
    attr_accessor :last_name
    # @return [String]
    attr_accessor :email
    # @return [List]
    attr_accessor :phone_numbers
    # @Validate(Validator: "NotNull")
    # @return [Integer]
    attr_accessor :profile_id

    # @return [String]
    attr_accessor :saved_level_id

    def self.properties
        {
            first_name: { name: 'firstName' },
            last_name: { name: 'lastName' },
            email: { name: 'email' },
            phone_numbers: { name: 'phoneNumbers', type: [Phone] },
            profile_id: { name: 'profileId' },
            saved_level_id: { name: 'savedLevelId' },
        }
    end

    def response_type() = ServiceStack::IdResponse
    def get_type_name() = 'CreatePlayer'
end

Ruby CreatePlayer DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other

HTTP + OTHER

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /jsonl/reply/CreatePlayer HTTP/1.1 
Host: blazor-gallery.servicestack.net 
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"firstName":"String","lastName":"String","email":"String","phoneNumbers":[{"kind":"Home","number":"String","ext":"String"}],"profileId":0,"savedLevelId":"00000000-0000-0000-0000-000000000000"}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"id":"String","responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}