Class: BungieSdk::Destiny2::Character
  
  
  
Overview
  
    
Class representing characters in Destiny 2
   
 
  
  Constant Summary
  
  Constants inherited
     from ApiAgent
  ApiAgent::BASE_URI
  Instance Attribute Summary
  
  Attributes inherited from ApiAgent
  #data
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  Methods inherited from ApiAgent
  #delete, #get, #initialize, #post, #put, #request, #run
  
  
    Instance Method Details
    
      
  
  
    #id  ⇒ Object 
  
  
  
  
    
      
9
10
11 
     | 
    
      # File 'lib/bungie_sdk/character.rb', line 9
def id
  data['characterId']
end 
     | 
  
 
    
      
  
  
    #membership_id  ⇒ Object 
  
  
  
  
    
      
21
22
23 
     | 
    
      # File 'lib/bungie_sdk/character.rb', line 21
def membership_id
  data['membershipId']
end 
     | 
  
 
    
      
  
  
    #membership_type  ⇒ Object 
  
  
  
  
    
      
15
16
17 
     | 
    
      # File 'lib/bungie_sdk/character.rb', line 15
def membership_type
  data['membershipType']
end 
     | 
  
 
    
      
  
  
    #vendors(can_purchase: true, enabled: true, components: [DestinyComponentType.Vendors, DestinyComponentType.VendorSales])  ⇒ Object 
  
  
  
  
    
      
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 
     | 
    
      # File 'lib/bungie_sdk/character.rb', line 37
def vendors(can_purchase: true,
            enabled:      true,
            components:   [DestinyComponentType.Vendors, DestinyComponentType.VendorSales])
  return @vendors unless @vendors.nil?
  vendor_data = run(get("#{character_url}/Vendors",
                        params: { components: components.join(',') })).body
  vendor_ids = [vendor_data['vendors']['data'].keys, vendor_data['sales']['data'].keys]
    .flatten
    .uniq
  vendor_hashes = vendor_ids.map do |id|
    {
      'vendorData' => vendor_data['vendors']['data'][id],
      'sales'      => vendor_data['sales']['data'][id]
    }
  end.select do |vendor|
    if vendor['vendorData'].nil?
      false
    else
      vendor['vendorData']['canPurchase'] == can_purchase &&
        vendor['vendorData']['enabled'] == enabled
    end
  end
  hydra    = Typhoeus::Hydra.new
  response = vendor_hashes.map do |hash|
    vendor = Vendor.new(hash)
    hydra.queue vendor.definition_request
    vendor
  end
  hydra.run
  @vendors = response
end
     |