Class: Gixen

Inherits:
Object
  • Object
show all
Defined in:
gixen.rb

Constant Summary collapse

CORE_GIXEN_URL =

:nodoc:

'https://www.gixen.com/api.php'
LISTING_FORMAT =

:nodoc:

[:break,
:itemid,
:endtime,
:maxbid,
:status,
:message,
:title,
:snipegroup,
:quantity,
:bidoffset]

Instance Method Summary collapse

Constructor Details

#initialize(user, pass, validate_ssl = false) ⇒ Gixen

Create a Gixen object for interacting with the user's Gixen account, placing snipes, deleting snipes, and determining what snipes have been set up.

user

an eBay username

pass

an eBay password

validate_ssl

true requests validation against the gixen cert file, false presumes the SSL is valid. Defaults to false.

Gixen uses eBay authentication for its users, so it doesn't have to have a different user/pass for its users.


35
36
37
38
39
# File 'gixen.rb', line 35

def initialize(user, pass, validate_ssl = false)
  @username = user
  @password = pass
  @validate_ssl = validate_ssl
end

Instance Method Details

#main_snipesarray of hashes

Lists all snipes currently set set, skipped, or done on Gixen's main server.

containing all the info for a given snipe, an empty array if none are listed on the main Gixen server. It raises a GixenError if there is a server-side problem.

Returns:

  • (array of hashes)

    an array where each entry is a hash


149
150
151
152
153
# File 'gixen.rb', line 149

def main_snipes
  response = submit({:listsnipesmain => 1})
  body = parse_response(response)
  handle_snipes_list(body)
end

#mirror_snipesarray of hashes

List all snipes currently set set, skipped, or done on Gixen's mirror server.

containing all the info for a given snipe, an empty array if none are listed on the Gixen Mirror server. It raises a GixenError if there is a server-side problem.

Returns:

  • (array of hashes)

    an array where each entry is a hash


161
162
163
164
165
# File 'gixen.rb', line 161

def mirror_snipes
  response = submit({:listsnipesmirror => 1})
  body = parse_response(response)
  handle_snipes_list(body)
end

#purgeboolean

Normally the snipes that are completed are still listed when retrieving snipes from the server; this method clears completed listings, so the list of snipes is just active snipes.

raises a GixenError if there is a server-side problem.

Returns:

  • (boolean)

    true if the purge completed successfully. It


173
174
175
176
177
# File 'gixen.rb', line 173

def purge
  response = submit({:purgecompleted => 1})
  body = parse_response(response).strip
  !!(body =~ /^OK COMPLETEDPURGED$/)
end

#snipe(item, bid, options = {}) ⇒ boolean

Place a snipe on an item (the auction item #) for bid (string amount).

item

the item number of the listing on eBay

bid

a string amount of currency-neutral money, for example “23.50”. The currency bid in will be the currency of the listing

options

A collection of optional parameters for setting snipe meta-data.

Optional parameters include:

  • :snipegroup => group number, e.g. :snipegroup => 1 (default: 0, no groups used)

  • :quantity => number (default: 1, single item auction) [obsolete]

  • :bidoffset => seconds before end (3, 6, 8, 10 or 15. Default value is 6)

  • :bidoffsetmirror => seconds before end (same as above, just for mirror server)

something other than 'OK ADDED' came back, and throws a GixenError if there is any server-side problem.

Returns:

  • (boolean)

    true if the snipe was successfully set, false if


110
111
112
113
114
# File 'gixen.rb', line 110

def snipe(item, bid, options = {})
  response = submit({:itemid => item, :maxbid => bid}.merge(options))
  body = parse_response(response).strip
  !!(body =~ /^OK #{item} ADDED$/)
end

#snipesarray of hashes

Lists all snipes set, skipped, or done on any Gixen server.

containing all the info for a given snipe, an empty array if no auctions are listed on either the main Gixen server or the Gixen Mirror server.

An additional field is added, :mirror, which is either true or false, depending on if the item hash came from the mirror server or not.

It raises a GixenError if there is a server-side problem.

Returns:

  • (array of hashes)

    an array where each entry is a hash


139
140
141
# File 'gixen.rb', line 139

def snipes
  sourcify_hashes(main_snipes) + sourcify_hashes(mirror_snipes, true)
end

#unsnipe(item) ⇒ boolean

Remove a snipe from an item (the auction item #).

something other than 'OK DELETED' came back, and throws a GixenError if there is any server-side problem.

Returns:

  • (boolean)

    true if the snipe was successfully deleted, false if


121
122
123
124
125
# File 'gixen.rb', line 121

def unsnipe(item)
  response = submit({:ditemid => item})
  body = parse_response(response).strip
  !!(body =~ /^OK #{item} DELETED$/)
end