def add(params={})
      # Pinboard expects multiple tags=foo,bar separated by comma instead of tag=foo&tag=bar
      params[:tags] = Array(params[:tags]).join(',') if params[:tags]

      # Pinboard expects datetime as UTC timestamp in this format:
      # 2010-12-11T19:48:02Z. Valid date range is Jan 1, 1 AD to January 1, 2100
      params[:dt] = params[:dt].iso8601 if params[:dt].is_a? Time

      # Pinboard expects replace, shared and toread as yes/no instead of true/false
      [:replace, :shared, :toread].each do |boolean|
        if params.has_key?(boolean) && !['yes', 'no'].include?(params[boolean])
          params[boolean] = params[boolean] ? 'yes' : 'no'
        end
      end

      options = create_params(params)
      result_code = self.class.post('/posts/add', options).parsed_response["result"]["code"]

      raise Error.new(result_code) if result_code != "done"

      result_code
    end
def add(params={})
      # Pinboard expects multiple tags=foo,bar separated by comma instead of tag=foo&tag=bar
      params[:tags] = Array(params[:tags]).join(',') if params[:tags]

      # Pinboard expects datetime as UTC timestamp in this format:
      # 2010-12-11T19:48:02Z. Valid date range is Jan 1, 1 AD to January 1, 2100
      params[:dt] = params[:dt].iso8601 if params[:dt].is_a? Time

      # Pinboard expects replace, shared and toread as yes/no instead of true/false
      [:replace, :shared, :toread].each do |boolean|
        if params.has_key?(boolean) && !['yes', 'no'].include?(params[boolean])
          params[boolean] = params[boolean] ? 'yes' : 'no'
        end
      end

      options = create_params(params)
      result_code = self.class.post('/posts/add', options).parsed_response["result"]["code"]

      raise Error.new(result_code) if result_code != "done"

      result_code
    end
Add a bookmark

 @param [Hash] params Arguments for this call
 @option params [String] :url the URL of the item (required)
 @option params [String] :description Title of the item (required)
 @option params [String] :extended Description of the item
 @option params [Array] :tags List of up to 100 tags
 @option params [Time] :dt creation time for this bookmark. Defaults to current
   time. Datestamps more than 10 minutes ahead of server time will be reset to
   current server time
 @option params [Boolean] :replace Replace any existing bookmark with this URL.
   Default is true. If set to false, will throw an error if bookmark exists
 @option params [Boolean] :shared Make bookmark public. Default is true unless
   user has enabled the "save all bookmarks as private" user setting, in which
   case default is false
 @option params [Boolean] :toread Marks the bookmark as unread (default: false)

 @return [String] "done" when everything went as expected
 @raise [Error] if result code is not "done"