Tumblr API Wrapper Code Hierarchy and Notes

It is important that you know how I've laid out the code before you even look at it. I like to keep things tidy therefore I used strict rules which I have to thing about when doing small things like making a new line in code, or bigger things like deciding on which folder to create a new class. The below will describe my thinking, rules and additional notes.

Code Hierarchy

First of all, each source code (class file) file has (or should have - contact me if one doesn't) the letters Flurr and a short copyright notice like this (this should NOT be removed, even in your own application/class file!):

'  __ _                 
' / _| |                
'| |_| |_   _ _ __ _ __ 
'|  _| | | | | '__| '__|
'| | | | |_| | |  | |   
'|_| |_|\__,_|_|  |_|

'Copyright (C) 2012, Rafal Marek Chmiel
'All rights reserved. http://flurr.codeplex.com/

So, the Tumblr API wrapper library has two sections. These being "tumblrMain" and "tumblrPostIt", both are in two folders. There is a main folder covering these two called "tumblr" and that folder is inside the Flurr solution. See below:
  • flurr (solution/project)
    • tumblr (folder)
      • tumblrMain (folder)
      • tumblrPostIt (folder)
      • tumblrEventArgs.vb (class file)
      • tumblrStatus.vb (class file)

"tumblrMain" Description

"tumblrMain" contains one more folder named "tumblrPosts" (and seven classes in that which contain properties which are later used) and two classes (those too are properties which take account and proxy information). Like this:
  • flurr (solution/project)
    • tumblr (folder)
      • tumblrMain (folder)
        • tumblrPosts (folder)
          • tumblrAudioPost.vb (class file)
          • tumblrChatPost.vb (class file)
          • tumblrLinkPost.vb (class file)
          • tumblrPhotoPost.vb (class file)
          • tumblrQuotePost.vb (class file)
          • tumblrTextPost.vb (class file)
          • tumblrVideoPost.vb (class file)
        • tumblrAccount.vb (class file)
        • tumblrProxy.vb (class file)
      • tumblrPostIt (folder)
      • tumblrEventArgs.vb (class file)
      • tumblrStatus.vb (class file)

"tumblrPostIt" Description

And lastly, the "tumblrPostIt" folder has two sub folders which include the actual code that gets YOUR info and posts it to the Tumblr API with the credentials, strings/media files that YOU provided. These are called "tumblrCheck" (checks Vimeo and Audio strings/audio files you provided) and "tumblrPost" (which included the stuff I described in my last sentence. Something like this:
  • flurr (solution/project)
    • tumblr (folder)
      • tumblrMain (folder)
        • tumblrPosts (folder)
          • tumblrAudioPost.vb (class file)
          • tumblrChatPost.vb (class file)
          • tumblrLinkPost.vb (class file)
          • tumblrPhotoPost.vb (class file)
          • tumblrQuotePost.vb (class file)
          • tumblrTextPost.vb (class file)
          • tumblrVideoPost.vb (class file)
        • tumblrAccount.vb (class file)
        • tumblrProxy.vb (class file)
      • tumblrPostIt (folder)
        • tumblrCheck (folder)
          • tumblrCheckAudio.vb (class file)
          • tumblrCheckVimeo.vb (class file)
        • tumblrPost (folder)
          • tumblrPostAudio.vb (class file)
          • tumblrPostChat.vb (class file)
          • tumblrPostLink.vb (class file)
          • tumblrPostPhoto.vb (class file)
          • tumblrPostQuote.vb (class file)
          • tumblrPostText.vb (class file)
          • tumblrPostVideo.vb (class file)
      • tumblrEventArgs.vb (class file)
      • tumblrStatus.vb (class file)

Notes

In this section I will write about additional notes about the code, in general. Note that the code is converted to C# so it may look a bit ugly - not really, lets say, "VB-like".

Variables and Comments

As you may (or may not) have noticed, every variable (well, nearly every) has a comment next to it like this (starting from the top and using "tumblrAudioPost.vb" as an example):

'  __ _                 
' / _| |                
'| |_| |_   _ _ __ _ __ 
'|  _| | | | | '__| '__|
'| | | | |_| | |  | |   
'|_| |_|\__,_|_|  |_|

'Copyright (C) 2012, Rafal Marek Chmiel
'All rights reserved. http://flurr.codeplex.com/

Imports System.Collections.Generic
Imports System.Text
Imports System.Web
Imports System.Net
Imports System.IO

Public Class tumblrAudioPost

    Inherits tumblrAccount

    Private strCaption As String = "" 'The user-supplied caption (string, N)
    Private strExternalURL As String = "" 'The URL of the site that hosts the audio file, not Tumblr (string, Y either external_url or data)
    Private strData As String = "" 'An audio file (string, Y either external_url or data)

The comment after one of the variables is actually a description taken from the Tumblr API documentation. The stuff after the description is (firstly) the data type of that variable and (secondly, and importantly) whether you have to provide data in that particular variable or not. For example:

Private strCaption As String = "" 'The user-supplied caption (string, N)
    Private strExternalURL As String = "" 'The URL of the site that hosts the audio file, not Tumblr (string, Y either external_url or data)
    Private strData As String = "" 'An audio file (string, Y either external_url or data)

In this example, "strCaption" is a string and you don't have to provide it. "strExternalURL" is also a string and you have to provide it if "strData" is null, and vice versa for "strData".

Please also note that the first three letters of a variable are the first three letters of its data type. A variable "strVar" would be a string variable, while a variable "intVar" would be an integer variable. This is just for quick recognition of one variable's data type.

"strGenerator"

As you may have noticed, I declare the "strGenerator" String variable at the beginning of each class of the "tumblrPostIt">"tumblrPost" folders. This is just for verification of who has made the post (the API or program, not the person!). This is the code:

Public strGenerator As String = "Flurr" 'Enter what you like in here(more in the documentation), however you MUST leave the string "Flurr" in it as well!

As noted in the comment, you MUST leave the String "Flurr" (without the quotes) in this String variable. You can include it like this: "(your program name) powered by Flurr" or "(your program name) is using Flurr". This is just for credit (to Flurr). Please note, its not as if this will be visible on EVERY post your program (my API wrapper) sends to Tumblr, it is pretty much invisible.

Last edited Mar 17, 2012 at 8:08 PM by RafalChmiel, version 9