Help Center

Resource: Pattern

Resource: Pattern

Data Elements

Name Read Only Required Type Length Notes
id Yes Number assignr.com primary key
name Yes String
position_patterns_attributes Repeating Element
  id Yes Number assignr.com primary key for "position pattern"
  position_name Yes String Name of position
  rank_order Yes Number Sort order for position

Notes

  • Each pattern has multiple "position pattern" records. This allows for multiple officials to be assigned to a game.

Validations

  • name must be unique.

Retrieve a list of patterns (INDEX)

Return a paginated list of patterns. Limit is 50 patterns per request.

Sample Response: GET /patterns.xml

<?xml version="1.0" encoding="UTF-8"?>
<patterns>
  <page>1</page>
  <pages>1</pages>
  <count>5</count>
  <pattern>
    <id>123</id>
    <name>4 officials</name>
    <position_patterns_attributes>
      <id>55</id>
      <position_name>Referee</position_name>
      <rank_order>1</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>56</id>
      <position_name>Umpire</position_name>
      <rank_order>2</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>57</id>
      <position_name>Head Linesman</position_name>
      <rank_order>3</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>773</id>
      <position_name>Team Fee</position_name>
      <rank_order>4</rank_order>
    </position_patterns_attributes>
  </pattern>
  <pattern>
    <id>1077</id>
    <name>3 other officials</name>
    <position_patterns_attributes>
      <id>3183</id>
      <position_name>Referee x</position_name>
      <rank_order>1</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>3184</id>
      <position_name>Referee x</position_name>
      <rank_order>2</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>3185</id>
      <position_name>Referee x</position_name>
      <rank_order>3</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>3186</id>
      <position_name>Referee x</position_name>
      <rank_order>4</rank_order>
    </position_patterns_attributes>
  </pattern>
  <pattern>
    <id>17</id>
    <name>4 officials</name>
    <position_patterns_attributes>
      <id>58</id>
      <position_name>Referee</position_name>
      <rank_order>1</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>59</id>
      <position_name>Umpire</position_name>
      <rank_order>2</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>60</id>
      <position_name>Head Linesman</position_name>
      <rank_order>3</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>61</id>
      <position_name>Line Judge</position_name>
      <rank_order>4</rank_order>
    </position_patterns_attributes>
  </pattern>
  <pattern>
    <id>18</id>
    <name>5 officials</name>
    <position_patterns_attributes>
      <id>62</id>
      <position_name>Referee</position_name>
      <rank_order>1</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>63</id>
      <position_name>Umpire</position_name>
      <rank_order>2</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>64</id>
      <position_name>Head Linesman</position_name>
      <rank_order>3</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>65</id>
      <position_name>Line Judge</position_name>
      <rank_order>4</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>66</id>
      <position_name>Back Judge</position_name>
      <rank_order>5</rank_order>
    </position_patterns_attributes>
  </pattern>
  <pattern>
    <id>6322</id>
    <name>6 officials</name>
    <position_patterns_attributes>
      <id>22021</id>
      <position_name>Referee</position_name>
      <rank_order>1</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>22022</id>
      <position_name>Referee</position_name>
      <rank_order>2</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>22023</id>
      <position_name>Referee</position_name>
      <rank_order>3</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>22024</id>
      <position_name>Referee</position_name>
      <rank_order>4</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>22025</id>
      <position_name>Referee</position_name>
      <rank_order>5</rank_order>
    </position_patterns_attributes>
    <position_patterns_attributes>
      <id>22026</id>
      <position_name>Referee</position_name>
      <rank_order>6</rank_order>
    </position_patterns_attributes>
  </pattern>
</patterns>

Sample Response: GET /patterns.json

{
    "page":1,
    "pages":1,
    "count":5,
    "patterns":
    [
        {
            "id":123,
            "name":"4 officials",
            "position_patterns_attributes":
            [
                {
                    "id":55,
                    "position_name":"Referee",
                    "rank_order":1
                },
                {
                    "id":56,
                    "position_name":"Umpire",
                    "rank_order":2
                },
                {
                    "id":57,
                    "position_name":"Head Linesman",
                    "rank_order":3
                },
                {
                    "id":773,
                    "position_name":"Team Fee",
                    "rank_order":4
                }
            ]
        },
        {
            "id":1077,
            "name":"3 other officials",
            "position_patterns_attributes":
            [
                {
                    "id":3183,
                    "position_name":"Referee x",
                    "rank_order":1
                },
                {
                    "id":3184,
                    "position_name":"Referee x",
                    "rank_order":2
                },
                {
                    "id":3185,
                    "position_name":"Referee x",
                    "rank_order":3
                },
                {
                    "id":3186,
                    "position_name":"Referee x",
                    "rank_order":4
                }
            ]
        },
        {
            "id":17,
            "name":"4 officials",
            "position_patterns_attributes":
            [
                {
                    "id":58,
                    "position_name":"Referee",
                    "rank_order":1
                },
                {
                    "id":59,
                    "position_name":"Umpire",
                    "rank_order":2
                },
                {
                    "id":60,
                    "position_name":"Head Linesman",
                    "rank_order":3
                },
                {
                    "id":61,
                    "position_name":"Line Judge",
                    "rank_order":4
                }
            ]
        },
        {
            "id":18,
            "name":"5 officials",
            "position_patterns_attributes":
            [
                {
                    "id":62,
                    "position_name":"Referee",
                    "rank_order":1
                },
                {
                    "id":63,
                    "position_name":"Umpire",
                    "rank_order":2
                },
                {
                    "id":64,
                    "position_name":"Head Linesman",
                    "rank_order":3
                },
                {
                    "id":65,
                    "position_name":"Line Judge",
                    "rank_order":4
                },
                {
                    "id":66,
                    "position_name":"Back Judge",
                    "rank_order":5
                }
            ]
        },
        {
            "id":6322,
            "name":"6 officials",
            "position_patterns_attributes":
            [
                {
                    "id":22021,
                    "position_name":"Referee",
                    "rank_order":1
                },
                {
                    "id":22022,
                    "position_name":"Referee",
                    "rank_order":2
                },
                {
                    "id":22023,
                    "position_name":"Referee",
                    "rank_order":3
                },
                {
                    "id":22024,
                    "position_name":"Referee",
                    "rank_order":4
                },
                {
                    "id":22025,
                    "position_name":"Referee",
                    "rank_order":5
                },
                {
                    "id":22026,
                    "position_name":"Referee",
                    "rank_order":6
                }
            ]
        }
    ]
}

Retrieve a specific pattern (SHOW)

The following commands will retrieve the pattern details for a specific pattern.

Sample Response: GET /patterns/123.xml

<?xml version="1.0" encoding="UTF-8"?>
<pattern>
  <id>123</id>
  <name>4 officials</name>
  <position_patterns_attributes>
    <id>55</id>
    <position_name>Referee</position_name>
    <rank_order>1</rank_order>
  </position_patterns_attributes>
  <position_patterns_attributes>
    <id>56</id>
    <position_name>Umpire</position_name>
    <rank_order>2</rank_order>
  </position_patterns_attributes>
  <position_patterns_attributes>
    <id>57</id>
    <position_name>Head Linesman</position_name>
    <rank_order>3</rank_order>
  </position_patterns_attributes>
  <position_patterns_attributes>
    <id>773</id>
    <position_name>Team Fee</position_name>
    <rank_order>4</rank_order>
  </position_patterns_attributes>
</pattern>

Sample Response: GET /patterns/123.json

{
    "pattern":
    {
        "id":123,
        "name":"4 officials",
        "position_patterns_attributes":
        [
            {
                "id":55,
                "position_name":"Referee",
                "rank_order":1
            },
            {
                "id":56,
                "position_name":"Umpire",
                "rank_order":2
            },
            {
                "id":57,
                "position_name":"Head Linesman",
                "rank_order":3
            },
            {
                "id":773,
                "position_name":"Team Fee",
                "rank_order":4
            }
        ]
    }
}

Create a Pattern (CREATE)

To create a pattern, use the POST command to /patterns.xml or /patterns.json.

The following status codes can be returned:

  • 201 Created: Successfully created a pattern. The response body will have an XML or JSON representation of the pattern you created.
  • 403 Unprocessable Entity: The pattern failed one or more validation checks.

Sample Request Body: POST /patterns.xml

<?xml version="1.0" encoding="UTF-8"?>
<pattern>
  <name>4 officials</name>
  <position_patterns_attributes>
    <position_name>Referee</position_name>
    <rank_order>1</rank_order>
  </position_patterns_attributes>
  <position_patterns_attributes>
    <position_name>Umpire</position_name>
    <rank_order>2</rank_order>
  </position_patterns_attributes>
  <position_patterns_attributes>
    <position_name>Head Linesman</position_name>
    <rank_order>3</rank_order>
  </position_patterns_attributes>
  <position_patterns_attributes>
    <position_name>Team Fee</position_name>
    <rank_order>4</rank_order>
  </position_patterns_attributes>
</pattern>

Sample Request Body: POST /patterns.json

{
    "pattern":
    {
        "name":"4 officials",
        "position_patterns_attributes":
        [
            {
                "position_name":"Referee",
                "rank_order":1
            },
            {
                "position_name":"Umpire",
                "rank_order":2
            },
            {
                "position_name":"Head Linesman",
                "rank_order":3
            },
            {
                "position_name":"Team Fee",
                "rank_order":4
            }
        ]
    }
}

Update a Pattern (UPDATE)

To update a pattern, send a PUT command to /patterns/123.xml or /patterns/123.json. The request body should be XML, JSON, or a URL encoded string. If you are only updating a specific field, you can just include the fields you wish to change. For example, if you only want to change an email address, the request can look like this:

PUT /patterns/123.xml
<pattern><name>Single</name></pattern>

PUT /patterns/123.xml
pattern[name]=Single

PUT /patterns/123.json
{"pattern":{"name":"Single"}}

Upon successful update of the record, the response code returned will be 200 (OK).

Delete a Pattern (DELETE)

To delete a pattern, issue a DELETE command to the pattern's URL:

DELETE /patterns/123.json

The server will respond with a status code 200 (OK) if the pattern was deleted, otherwise you will see an error response (422 Unprocessable Entity). No response body is rendered.

Validation Errors

If you try to create, update, or delete a pattern, and the change that you want to make validates one or more assignr.com validation rules, assignr.com will respond with a 422 Unprocessable Entity error. The response body will contain details about the error, like this:

<?xml version="1.0" encoding="UTF-8"?>
<error>
  <messages>
    <message>Name is already taken.</message>
  </messages>
</error>

If JSON is requested, it will look like this:

{"error": [
    {"message": "Name is already taken."}
  ]
}