LibreMoney

2. Основная часть

2.8. API (RestAPI)

Операции с опросами

Create Poll

Создать новый опрос

Запрос

http://localhost:1400/api/createPoll?
     name=NAME&
     description=DESCRIP&
     minNumberOfOptions=MINOPTIONS&
     maxNumberOfOptions=MAXOPTIONS&
     optionsAreBinary=BINARY&
     option1=OPTION1&
     option2=OPTION2&
     option3=OPTION3&
     secretPhrase=SECRET&
     fee=FEE&
     deadline=DEADLINE&
     referencedTransactionFullHash=REFTXHASH&
     broadcast=BROAD

Где:

Ответ

{
     "fullHash":                 "FULLHASH", 
     "signatureHash":            "SIGHASH", 
     "transactionBytes":         "TXBYTES", 
     "hash":                     "HASH", 
     "transaction":              "TX", 
     "broadcasted":              BROAD, 
     "unsignedTransactionBytes": "UNTXBYTES" 
}

Где:

Пример

Запрос:

http://localhost:1400/api/createPoll?
     name=Testing123&
     description=Testing&
     minNumberOfOptions=1&
     maxNumberOfOptions=1&
     option1=yes&
     option2=no&
     secretPhrase=MySuperSecretPasswordThatIsNotActuallyPostedHereOrIsEvenRealSoDoNotEvenTryIt&
     fee=100000000&
     deadline=1440

Ответ:

{ 
     "fullHash":                 "7ef9e19d0c7943002fd98a7ae08f1b4a1d473c67796f89225b167fd4913ce73f", 
     "signatureHash":            "a76722be0652d5c88cb7292d1cb04ea299eaea74c35ad726e868d08799946c38", 
     "transactionBytes":         "010234fbda00a005668683e673274c671802492d6f54cdc33d247aa426e...", 
     "hash":                     "940383ff1bf177d4e4fee05c78865b12ace2570152c64570219dfc0aa10c246b", 
     "transaction":              "18991918535014782", 
     "broadcasted":              true, 
     "unsignedTransactionBytes": "010234fbda00a005668683e673274c671802492d6f54cdc33d247..." 
}

Get Poll

Получить информацию о заданном опросе

Запрос

http://localhost:1400/api/getPoll?
     poll=POLL

Где:

Ответ

{ 
     "description":        "DESCRIP", 
     "name":               "NAME", 
     "maxNumberOfOptions": MAXOPTIONS, 
     "optionsAreBinary":   BINARY, 
     "voters":             [VOTERS], 
     "minNumberOfOptions": MINOPTIONS, 
     "options":            [OPTIONS] 
}

Where:

Пример

Request:

http://localhost:1400/api/getPoll?
     poll=15826354927269615782

Response:

{ 
     "description":        "Does this work?", 
     "name":               "Test", 
     "maxNumberOfOptions": 1, 
     "optionsAreBinary":   false, 
     "voters":             [], 
     "minNumberOfOptions": 1, 
     "options":            [ "Yes", "No", "I don't know" ] 
}

Get Poll IDs

Возвращает ID (идентификаторы) всех голосований

Запрос

http://localhost:1400/api/getPollIds

Ответ

{ 
     "pollIds": 
     [ 
          "POLLID", 
          ...
     ]
}

Где:

Пример

Запрос:

http://localhost:1400/api/getPollIds

Ответ:

{ 
     "pollIds": 
     [ 
          "15826354927269615782", 
          "8883605113950920958" 
     ]
}

Cast Vote

Проголосовать в опросе

Запрос

http://localhost:1400/api/castVote?
     poll=NAME&
     vote1=VOTE1&
     vote2=VOTE2&
     vote3=VOTE3&
     secretPhrase=SECRET&
     fee=FEE&
     deadline=DEADLINE&
     referencedTransactionFullHash=REFTXHASH&
     broadcast=BROAD

Где:

Ответ

{
     "fullHash":                 "FULLHASH", 
     "signatureHash":            "SIGHASH", 
     "transactionBytes":         "TXBYTES", 
     "hash":                     "HASH", 
     "transaction":              "TX", 
     "broadcasted":              BROAD, 
     "unsignedTransactionBytes": "UNTXBYTES" 
}

Where:

Пример

Запрос:

http://localhost:1400/api/castVote?
     poll=18991918535014782&
     vote1=yes&
     secretPhrase=MySuperSecretPasswordThatIsNotActuallyPostedHereOrIsEvenRealSoDoNotEvenTryIt&
     fee=100000000&
     deadline=1440

Ответ:

{ 
     "fullHash":                 "637ea3215258adef61f7fc5a90eff6435d1a7ad8c3790d5855c6943b9aff1daf", 
     "signatureHash":            "a6745e26165e9c7870c85bd174348e4e72c825378cfb71760e04f08e30879fa6", 
     "transactionBytes":         "010314feda00a005668683e673274c671802492d6f54cdc33...", 
     "hash":                     "10ee68836162f6a8e2559a6dbcbc41c4db4b7441e6ff321f01b268d761c6916d", 
     "transaction":              "17270557255810645603", 
     "broadcasted":              true, 
     "unsignedTransactionBytes": "010314feda00a005668683e673274c671802492d6f54cdc33d247aa426e7..." 
}