Badges - danopia/deviantart-difi GitHub Wiki

This class appears to manipulate the badge display on a user's page.

More information about this class can be acquired by studying the badges.js file.

checkUser

Seems to check user privs?

Usage

  • Check user privs to pop sign up if needed

Params

None

Response

Returned null in the wild

getModal

REMOVED – This call seems to have been removed and not used anymore.

Returns a modal Dialog that would give a badge.

Usage

  • Called/loaded when the "give" button is clicked for a certain badge.

Params

  • badge: string (i.e. "llama")
  • deviantid: number (Deviant to give badge to, i.e. 181319)

Response

Returns a typical Dialog object.

giveBadge

REMOVED – This call seems to have been removed and not used anymore.

Actually gives a badge to a user.

NOTE: Request includes the user's password!

Usage

  • Called/loaded when the "give" modal dialog is submitted.

Params

  • badge: string (i.e. "llama")
  • deviantid: number (Deviant badge was given to, i.e. 181319)
  • ???: string ("1") (TODO: redundant badge type? quantity?)
  • password: string (current user's password, used for verification)
  • ???: number (1) (TODO: redundant badge type? quantity?)
  • ???: number (0) (TODO: cost?)
  • ???: string (TODO: appears to be a bytearray and/or checksum?)
  • tradeid: number, 0 if no trade (i.e. 8919)

Response

Returns some info on the target, their badge, and a notification.

{"user":
  {"userid":181319,
   "username":"snowmask",
   "realname":"... DANGER ZONE!!",
   "joindate":"1001220377",
   "symbol":"`",
   "usericon":"57",
   "gender":"f"},
 "badge":
  {"id":null,
   "typeid":1,
   "name":"llama",
   "title":"Llama",
   "description":"Llamas are awesome!",
   "html":"<div class=\"badge-stack badge-variant-normal badge-llama\" title=\"Llama: Llamas are awesome!\"  name=\"gmi-GBadge\" id=\"gmi-GBadge\" data-gmiclass=\"GBadge\" gmi-badgetypeid=\"1\"><img src=\"http:\/\/st.deviantart.net\/badges\/llama.gif\" alt=\"\"  \/><\/div>",
   "rules":["This badge can be given by you only once to each person."],
   "position":null,
   "url":"http:\/\/.deviantart.com\/badges\/llama\/"},
 "tradeid":8919,
 "quantity":1,
 "html":"    <div class=\"modal-dialog badgeModal\" id=\"givebadgeModalReceipt\" style=\"display:none;\"> . . . <\/div>",
 "url":"http:\/\/snowmask.deviantart.com\/badges\/361\/"}

setBadgeDisplay

DeviantArt allows a user to "lock" a Llama Badge in a certain level. To do so, you need to open the Llama Badge page in your badges page, and click on a Llama level.

Usage

  • When switching Llama levels

Params

  • user_id: string (e.g. "27200967")
  • badge_id: string (e.g. "10622930")
  • threshold: is the number of Llama level (e.g. "1000" for Fancy Llama, or "0" to unlock.)

NOTE: The number of Llama level is accessible via the rel="" attribute on the level link.

buyAccessory

Buys the bowtie and sunglasses accessory for Llama Badges?

Params

  • user_id: string (e.g. "27200967")
  • badge_id: string (e.g. "6905452")
  • aid: ???
  • userpass: ???
  • tosagree: integer (e.g. 0 or 1)

Response

TODO

toggleAccessory

Toggles the bowtie and sunglasses accessory for Llama Badges?

Params

  • user_id: string (e.g. "27200967")
  • badge_id: string (e.g. "6905452")
  • aid: ???

Response

The same as the featureBadge response.

unfeatureBadge

This removes a badge to from "featured badges" section on your userpage. This must be sent with the POST method.

Usage

  • When removing one Badge from Featured Badges

Params

  • user_id: string (e.g. "27200967")
  • badge_id: string (e.g. "10622930")

To find the badge_id, please refer to the featureBadge method's parameters section.

Response

The same as featureBadge response.

unfeatureAllBadges

Usage

  • When clicking "Clear all featured badges"

Params

  • user_id: string (e.g. "27200967")

Response

null.

removeTrade

Removes a trade?

Usage

  • Seen on the llamatrade page. Not sure what does it do.

Params

  • trade_id: number (e.g. "206072")

Response

Success

TODO

Error

{
    "status": "FAIL",
    "content":
    {
        "error": {
            "code": "ERR_TRADE",
            "human": "Can not delete that trade."
        }
    }
}

featureBadge

This adds a badge to your "featured badges" section on your userpage. This must be sent with the POST method.

Usage

  • When featuring a badge in the badges page of a user

Params

  • user_id: string (e.g. "27200967")
  • badge_id: string (e.g. "6905452")
  • newpos: string (e.g. "1")

The Badge id can be found on the /badges/ page of a user's profile. If you click on a badge, then you'll be taken to a page like http://spyed.deviantart.com/badges/1/. The number in the URL is the badge ID.

Response

  • id: number (e.g. 6905452 or 13043542)
  • typeid: number (e.g. 1 or 17)
  • name: string (e.g. "Llama" or "cake")
  • title: string (e.g. "King Llama" or "Delicious Cake")
  • description: string (e.g. "Llamas are awesome!" or "Delicious Cake")
  • html: string , e.g.:
<div class="badge-stack badge-variant-normal badge-llama" title="King Llama: Llamas are awesome! (4638)"  name="gmi-GBadge" id="gmi-GBadge" data-gmiclass="GBadge" gmi-id="6905452" gmi-badgetypeid="1" gmi-position="3" gmi-owner="27200967"><img src="https://st.deviantart.net/badges/llama_king.gif" alt=""  /></div>
⚠️ **GitHub.com Fallback** ⚠️