Class: TempmailSdk::Providers::Zhujump::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/tempmail_sdk/providers/zhujump.rb

Overview

使用标准库 Net::HTTP 实现带 cookie jar 的会话请求 此 provider 需要在注册/登录/创建邮箱的多步流程中保持 cookie

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url) ⇒ Session

Returns a new instance of Session.



70
71
72
73
74
75
76
77
78
# File 'lib/tempmail_sdk/providers/zhujump.rb', line 70

def initialize(base_url)
  @base_url = base_url
  @cookies = {}
  config = Config.get_config
  @timeout = config.timeout || 15
  @proxy = config.proxy
  @insecure = config.insecure
  @extra_headers = config.headers || {}
end

Instance Attribute Details

#cookiesObject (readonly)

Returns the value of attribute cookies.



68
69
70
# File 'lib/tempmail_sdk/providers/zhujump.rb', line 68

def cookies
  @cookies
end

Instance Method Details

#get(path, extra_headers: {}) ⇒ Object



80
81
82
# File 'lib/tempmail_sdk/providers/zhujump.rb', line 80

def get(path, extra_headers: {})
  do_request(:get, path, extra_headers: extra_headers)
end

#post(path, json: nil, form: nil, extra_headers: {}) ⇒ Object



84
85
86
# File 'lib/tempmail_sdk/providers/zhujump.rb', line 84

def post(path, json: nil, form: nil, extra_headers: {})
  do_request(:post, path, json: json, form: form, extra_headers: extra_headers)
end