Class: Pindo::TgateClient

Inherits:
Object
  • Object
show all
Defined in:
lib/pindo/client/tgateclient.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_usrl: nil, req_config: nil) ⇒ TgateClient

Returns a new instance of TgateClient.



17
18
19
20
21
# File 'lib/pindo/client/tgateclient.rb', line 17

def initialize(base_usrl:nil, req_config:nil)
  @base_url = base_usrl
  @req_config = req_config

end

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url.



15
16
17
# File 'lib/pindo/client/tgateclient.rb', line 15

def base_url
  @base_url
end

#requests_configObject

Returns the value of attribute requests_config.



14
15
16
# File 'lib/pindo/client/tgateclient.rb', line 14

def requests_config
  @requests_config
end

Instance Method Details

#get_gate_status(device_info: nil) ⇒ Object



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
# File 'lib/pindo/client/tgateclient.rb', line 24

def get_gate_status(device_info:nil)

    querry_params = device_info
    querry_params = {
        market:"iOS",
        device_id:device_info.device_id,
        idfa:device_info.idfa,
        sbsid:device_info.sbsid,
        sutid:device_info.sutid,
        tzlid:device_info.tzlid
        # idfv:device_info.idfv
    }

    req_url = URI.join(@base_url, @req_config["get_gate_status"])  
    
    con = Faraday.new 
    res = con.get do |req|
        req.url req_url
        req.headers['Content-Type'] = 'application/json'
        req.params = querry_params
    end

    result_status = nil
    if !res.body.nil?
        result_status = JSON.parse(res.body)    
    end

    return  result_status
end

#post_update_gate_status(env_mode: nil, type: nil, to_status: nil, device_info: nil) ⇒ Object



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
# File 'lib/pindo/client/tgateclient.rb', line 54

def post_update_gate_status(env_mode:nil, type:nil, to_status:nil, device_info:nil)

    req_url = URI.join(@base_url, @req_config["update_gate_status"])  

    body_params = {
        env:env_mode,
        type:type,
        to_status:to_status,
        market:"iOS",
        device_id:device_info.device_id,
        idfa:device_info.idfa,
        sbsid:device_info.sbsid,
        sutid:device_info.sutid,
        tzlid:device_info.tzlid
    }
    
    puts    
    puts "#{env_mode}环境更新#{type}#{to_status}状态..."
    # puts "env: #{env_mode}".bold.blue
    # puts "type: #{type}".bold.blue
    # puts "to_status: #{to_status}".bold.blue
    # puts

    con = Faraday.new 
    res = con.post do |req|
        req.url req_url
        req.headers['Content-Type'] = 'application/json'
        req.body = body_params.to_json
    end

    result_status = nil
    if !res.body.nil?
        result_status = JSON.parse(res.body)    
    end
    

    if !result_status.nil? && !result_status["meta"].nil? && result_status["meta"]["code"].to_s.eql?("200") && !result_status["data"].nil? && result_status["data"]["is_success"]
        puts "更新成功!!" 
        puts    
    end
    # puts 
    
    return  result_status

    
end