Class: Haruna::Client
- Inherits:
-
API
- Object
- API
- Haruna::Client
show all
- Defined in:
- lib/haruna/client.rb
Constant Summary
Constants inherited
from API
API::ACCEPT_ENCODING, API::ACCEPT_LANGUAGE, API::API_VER, API::CONTENT_TYPE, API::END_POINT, API::REFERER, API::USER_AGENT
Instance Attribute Summary
Attributes inherited from API
#conn
Instance Method Summary
collapse
Methods inherited from API
#call, #setup_param
Constructor Details
#initialize(token, proxy = nil) ⇒ Client
Returns a new instance of Client.
5
6
7
|
# File 'lib/haruna/client.rb', line 5
def initialize(token, proxy=nil)
super(token, proxy)
end
|
Instance Method Details
#get_member_deck_port ⇒ Object
20
21
22
|
# File 'lib/haruna/client.rb', line 20
def get_member_deck_port
call("api_get_member", "deck_port")
end
|
#req_hokyu_charge(kind, ship_id_arr) ⇒ Object
kind
1: oil?
2: bullet?
3: oil + bullet?
28
29
30
31
32
|
# File 'lib/haruna/client.rb', line 28
def req_hokyu_charge(kind, ship_id_arr)
validate_supply_kind(kind)
validate_ship_ids(ship_id_arr)
call("api_req_hokyu", "charge", api_kind: kind, api_id_items: ship_id_arr.join(","))
end
|
#req_mission_result(deck_id) ⇒ Object
15
16
17
18
|
# File 'lib/haruna/client.rb', line 15
def req_mission_result(deck_id)
validate_deck_id(deck_id)
call("api_req_mission", "result", api_deck_id: deck_id)
end
|
#req_mission_start(deck_id, mission_id) ⇒ Object
9
10
11
12
13
|
# File 'lib/haruna/client.rb', line 9
def req_mission_start(deck_id, mission_id)
validate_deck_id(deck_id)
validate_mission_id(mission_id)
call("api_req_mission", "start", api_deck_id: deck_id, api_mission_id: mission_id)
end
|
#validate_deck_id(deck_id) ⇒ Object
35
36
37
|
# File 'lib/haruna/client.rb', line 35
def validate_deck_id(deck_id)
raise ArgumentError, "deck id must be between 1~4" unless deck_id.between?(1, 4)
end
|
#validate_mission_id(mission_id) ⇒ Object
39
40
41
|
# File 'lib/haruna/client.rb', line 39
def validate_mission_id(mission_id)
raise ArgumentError, "mission_id must be positive" unless 0 < mission_id
end
|
#validate_ship_ids(ship_id_arr) ⇒ Object
47
48
49
50
|
# File 'lib/haruna/client.rb', line 47
def validate_ship_ids(ship_id_arr)
raise ArgumentError, "at least 1 ship id is required" if ship_id_arr.empty?
raise ArgumentError, "at least 1 ship id is required" unless ship_id_arr.select{|id| id <= 0 }.empty?
end
|
#validate_supply_kind(kind) ⇒ Object
43
44
45
|
# File 'lib/haruna/client.rb', line 43
def validate_supply_kind(kind)
raise ArgumentError, "kind must be between 1~3" unless kind.between?(1, 3)
end
|