+{Promise} = require 'q'
 fs = require 'fs'
 mime = require 'mime'
+oauth = require 'oauth'
 request = require 'request'
 wsse = require 'wsse'
 xml2js = require 'xml2js'
-{Promise} = require 'q'
 
 # Hatena::Fotolife API wrapper
 #


  _request: ({ method, path, body, statusCode }, callback) ->
    callback = callback ? (->)
    token = @_wsse.getUsernameToken @_username, @_apikey, nonceBase64: true
    params = {}
    params.method = method
    params.url = Fotolife.BASE_URL + path
    params.headers =
      'Authorization': 'WSSE profile="UsernameToken"',
      'X-WSSE': 'UsernameToken ' + token
    promise = if body? then @_toXml(body) else Promise.resolve(null)
    promise
      .then (body) =>

  # params:
  #   options: (required)
  #   - type     : authentication type. default `'wsse'`
  #   (type 'wsse')
  #   - username : wsse authentication username. (required)
  #   - apikey   : wsse authentication apikey. (required)
  #   (type 'oauth')
  #   - consumerKey       : oauth consumer key. (required)
  #   - consumerSecret    : oauth consumer secret. (required)
  #   - accessToken       : oauth access token. (required)
  #   - accessTokenSecret : oauth access token secret. (required)
  constructor: ({
    type,
    username,
    apikey,
    consumerKey
    consumerSecret,
    accessToken,
    accessTokenSecret
  }) ->
    @_type = type ? 'wsse'
    @_username = username
    @_apikey = apikey
    @_consumerKey = consumerKey
    @_consumerSecret = consumerSecret
    @_accessToken = accessToken
    @_accessTokenSecret = accessTokenSecret
    @_wsse = wsse()

  # POST PostURI (/atom/post)
