Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: dbaaebc675
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 338 lines (275 sloc) 8.345 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
module Analytics
  class Property
    include HappyMapper

    tag 'property'
    namespace 'http://schemas.google.com/analytics/2009'
    attribute :name, String
    attribute :value, String
  end

  class Entry
    include HappyMapper

    tag 'entry'
    element :id, String
    element :updated, DateTime
    element :title, String
    element :table_id, String, :namespace => 'http://schemas.google.com/analytics/2009', :tag => 'tableId'
    has_many :properties, Property
  end

  class Feed
    include HappyMapper

    tag 'feed'
    element :id, String
    element :updated, DateTime
    element :title, String
    has_many :entries, Entry
  end
end

class Feature
  include HappyMapper
  element :name, String, :tag => '.|.//text()'
end

class FeatureBullet
  include HappyMapper

  tag 'features_bullets'
  has_many :features, Feature
  element :bug, String
end

class Product
  include HappyMapper

  element :title, String
  has_one :feature_bullets, FeatureBullet
end

module FamilySearch
  class Person
    include HappyMapper

    attribute :version, String
    attribute :modified, Time
    attribute :id, String
  end

  class Persons
    include HappyMapper
    has_many :person, Person
  end

  class FamilyTree
    include HappyMapper

    tag 'familytree'
    attribute :version, String
    attribute :status_message, String, :tag => 'statusMessage'
    attribute :status_code, String, :tag => 'statusCode'
    has_one :persons, Persons
  end
end

module FedEx
  class Address
    include HappyMapper

    tag 'Address'
    namespace 'http://fedex.com/ws/track/v2'
    element :city, String, :tag => 'City'
    element :state, String, :tag => 'StateOrProvinceCode'
    element :zip, String, :tag => 'PostalCode'
    element :countrycode, String, :tag => 'CountryCode'
    element :residential, Boolean, :tag => 'Residential'
  end

  class Event
    include HappyMapper

    tag 'Events'
    namespace 'http://fedex.com/ws/track/v2'
    element :timestamp, String, :tag => 'Timestamp'
    element :eventtype, String, :tag => 'EventType'
    element :eventdescription, String, :tag => 'EventDescription'
    has_one :address, Address
  end

  class PackageWeight
    include HappyMapper

    tag 'PackageWeight'
    namespace 'http://fedex.com/ws/track/v2'
    element :units, String, :tag => 'Units'
    element :value, Integer, :tag => 'Value'
  end

  class TrackDetails
    include HappyMapper

    tag 'TrackDetails'
    namespace 'http://fedex.com/ws/track/v2'
    element :tracking_number, String, :tag => 'TrackingNumber'
    element :status_code, String, :tag => 'StatusCode'
    element :status_desc, String, :tag => 'StatusDescription'
    element :carrier_code, String, :tag => 'CarrierCode'
    element :service_info, String, :tag => 'ServiceInfo'
    has_one :weight, PackageWeight, :tag => 'PackageWeight'
    element :est_delivery, String, :tag => 'EstimatedDeliveryTimestamp'
    has_many :events, Event
  end

  class Notification
    include HappyMapper

    tag 'Notifications'
    namespace 'http://fedex.com/ws/track/v2'
    element :severity, String, :tag => 'Severity'
    element :source, String, :tag => 'Source'
    element :code, Integer, :tag => 'Code'
    element :message, String, :tag => 'Message'
    element :localized_message, String, :tag => 'LocalizedMessage'
  end

  class TransactionDetail
    include HappyMapper

    tag 'TransactionDetail'
    namespace 'http://fedex.com/ws/track/v2'
    element :cust_tran_id, String, :tag => 'CustomerTransactionId'
  end

  class TrackReply
    include HappyMapper

    tag 'TrackReply'
    namespace 'http://fedex.com/ws/track/v2'
    element :highest_severity, String, :tag => 'HighestSeverity'
    element :more_data, Boolean, :tag => 'MoreData'
    has_many :notifications, Notification, :tag => 'Notifications'
    has_many :trackdetails, TrackDetails, :tag => 'TrackDetails'
    has_one :tran_detail, TransactionDetail, :tab => 'TransactionDetail'
  end
end

class Place
  include HappyMapper
  element :name, String
end

class Radar
  include HappyMapper
  has_many :places, Place
end

class Post
  include HappyMapper

  attribute :href, String
  attribute :hash, String
  attribute :description, String
  attribute :tag, String
  attribute :time, Time
  attribute :others, Integer
  attribute :extended, String
end

class User
  include HappyMapper

  element :id, Integer
  element :name, String
  element :screen_name, String
  element :location, String
  element :description, String
  element :profile_image_url, String
  element :url, String
  element :protected, Boolean
  element :followers_count, Integer

  attr_accessor :after_parse_called
  attr_accessor :after_parse2_called

  after_parse do |doc|
    doc.after_parse_called = true
  end

  after_parse do |doc|
    doc.after_parse2_called = true
  end
end

class Status
  include HappyMapper

  element :id, Integer
  element :text, String
  element :created_at, Time
  element :source, String
  element :truncated, Boolean
  element :in_reply_to_status_id, Integer
  element :in_reply_to_user_id, Integer
  element :favorited, Boolean
  element :non_existent, String, :tag => 'dummy', :namespace => 'fake'
  has_one :user, User
end

class CurrentWeather
  include HappyMapper

  tag 'ob'
  namespace 'http://www.aws.com/aws'
  element :temperature, Integer, :tag => 'temp'
  element :feels_like, Integer, :tag => 'feels-like'
  element :current_condition, String, :tag => 'current-condition', :attributes => {:icon => String}
end

class Address
  include HappyMapper

  tag 'address'
  element :street, String
  element :postcode, String
  element :housenumber, String
  element :city, String
  element :country, String
end

class MultiStreetAddress
  include HappyMapper
  
  tag 'address'
  # allow primitive type to be collection
  has_many :street_address, String, :tag => "streetaddress"
  element :city, String
  element :state_or_providence, String, :tag => "stateOfProvidence"
  element :zip, String
  element :country, String
end

# for type coercion
class ProductGroup < String; end

module PITA
  class Item
    include HappyMapper

    tag 'Item' # if you put class in module you need tag
    element :asin, String, :tag => 'ASIN'
    element :detail_page_url, URI, :tag => 'DetailPageURL', :parser => :parse
    element :manufacturer, String, :tag => 'Manufacturer', :deep => true
    element :point, String, :tag => 'point', :namespace => 'http://www.georss.org/georss'
    element :product_group, ProductGroup, :tag => 'ProductGroup', :deep => true, :parser => :new, :raw => true
  end

  class Items
    include HappyMapper

    tag 'Items' # if you put class in module you need tag
    element :total_results, Integer, :tag => 'TotalResults'
    element :total_pages, Integer, :tag => 'TotalPages'
    has_many :items, Item
  end
end

module GitHub
  class Commit
    include HappyMapper

    tag "commit"
    element :url, String
    element :tree, String
    element :message, String
    element :id, String
    element :'committed-date', Date
  end
end

module Backpack
  class Note
    include HappyMapper

    attribute :id, Integer
    attribute :title, String
    attribute :created_at, Date

    content :body
  end
end

module Intrade
  class EpochMillis
    def self.parse(millis); Time.at(millis.to_i / 1000); end
  end

  class Message
    include HappyMapper

    tag 'msg'
    attribute :message_id, Integer, :tag => 'msgID'
    element :contract_id, Integer, :tag => 'conID'
    element :symbol, String, :tag => 'symbol'
    element :is_read, Boolean, :tag => 'readFlag'
    element :type, String, :tag => 'type'
    element :text, String, :tag => 'msg'
    element :price, Float, :tag => 'price'
    element :quantity, Integer, :tag => 'quantity'
    element :side, String, :tag => 'side'
    element :timestamp, EpochMillis, :tag => 'timestamp', :parser => :parse
  end

  class Messages
    include HappyMapper

    tag 'tsResponse'
    attribute :operation, String, :tag => 'requestOp'
    attribute :timestamp, EpochMillis, :tag => 'timestamp', :parser => :parse
    attribute :result_code, Integer, :tag => 'resultCode'
    element :error_message, String, :tag => 'faildesc'
    element :session_key, String, :tag => 'sessionData'
    has_many :messages, Message, :tag => 'msg', :xpath => './msg'
  end
end

Something went wrong with that request. Please try again.