anchor.diff:  -include_lib("eunit/include/eunit.hrl").
   
   -export([
  -          fetch_org_id/1,
  -          fetch_org_id/2
  +          fetch_org_id/1
           ]).
   
   %% @doc Fetch an org_id by querying opscode-account organizations endpoint
  
positive.code: -spec fetch_org_id(OrgName :: string()) -> binary() | not_found.
  fetch_org_id(OrgName) ->
      {ok, Key} = chef_keyring:get_key(pivotal),
      Headers =  chef_authn:sign_request(Key, <<"pivotal">>,
                                         <<"get">>, now,
                                         path(OrgName)),
      fetch_org_id(OrgName, Headers).
  
  fetch_org_id(OrgName, Headers) ->
      Url = path(OrgName),
      FullHeaders = [{"Accept", "application/json"}|Headers],
      case ibrowse:send_req(Url, FullHeaders, get) of
          {ok, "404", _ResponseHeaders, _ResponseBody} ->
              not_found;
          {ok, Code, ResponseHeaders, ResponseBody} ->
  
negative.code:             throw({error, Reason})
      end.
  
  url(OrgName) ->
      {ok, ErchefHost} = application:get_env(pushy, erchef_root_url),
      ErchefHost ++ path(OrgName).
  
  path(OrgName) ->
      "/organizations/" ++ OrgName.
  
  %%
  %% Internal functions
  