Sha256: c8cc3a9f4cc2bb0df397202432c2c9eccd78a6da36e3d239355ba7f7a5692bac

Contents?: true

Size: 972 Bytes

Versions: 1

Compression:

Stored size: 972 Bytes

Contents

require 'httparty'

class UpdatePlayer

  include HTTParty
  base_uri "https://balldontlie.io/api/v1"

  attr_reader :id, :first_name, :last_name, :height_feet, :height_inches, :position, :team_id, :weight_pounds

  def initialize(id, first_name=nil, last_name=nil, height_feet=nil,
                 height_inches=nil , position=nil, team_id=nil, weight_pounds=nil)
    @id = id
    @first_name = first_name
    @last_name = last_name
    @height_feet = height_feet
    @height_inches = height_inches
    @position = position
    @team_id = team_id
    @weight_pounds = weight_pounds
  end

  def call
    args = {
      id: id,
      first_name: first_name,
      last_name: last_name,
      height_feet: height_feet,
      height_inches: height_inches,
      position: position,
      team_id: team_id,
      weight_pounds: weight_pounds
    }
    self.class.patch("/players/#{args[:id]}", :body => args, :headers => { 'Content-Type' => 'application/json' })
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unit_st-0.1.6 lib/unit_st/update_player.rb