File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,16 @@ def endpoint
50
50
end
51
51
52
52
def blob_endpoint
53
- @blob_endpoint ||= Line ::Bot ::API ::DEFAULT_BLOB_ENDPOINT
53
+ unless @blob_endpoint
54
+ if endpoint == Line ::Bot ::API ::DEFAULT_ENDPOINT
55
+ @blob_endpoint = Line ::Bot ::API ::DEFAULT_BLOB_ENDPOINT
56
+ else
57
+ # for backward compatible
58
+ @blob_endpoint = endpoint
59
+ end
60
+ end
61
+
62
+ @blob_endpoint
54
63
end
55
64
56
65
# @return [Hash]
Original file line number Diff line number Diff line change @@ -39,6 +39,29 @@ def generate_client
39
39
stub_request ( :post , Line ::Bot ::API ::DEFAULT_ENDPOINT ) . to_return { |request | { body : request . body , status : 200 } }
40
40
end
41
41
42
+ it 'default endpoint' do
43
+ client = Line ::Bot ::Client . new
44
+ expect ( client . endpoint ) . to eq Line ::Bot ::API ::DEFAULT_ENDPOINT
45
+ expect ( client . blob_endpoint ) . to eq Line ::Bot ::API ::DEFAULT_BLOB_ENDPOINT
46
+ end
47
+
48
+ it 'rewrite endpoint' do
49
+ client = Line ::Bot ::Client . new do |config |
50
+ config . endpoint = 'https://example.com/api/v1'
51
+ config . blob_endpoint = 'https://example.com/api-data/v1'
52
+ end
53
+ expect ( client . endpoint ) . to eq 'https://example.com/api/v1'
54
+ expect ( client . blob_endpoint ) . to eq 'https://example.com/api-data/v1'
55
+ end
56
+
57
+ it 'rewrite endpoint and backward compatible' do
58
+ client = Line ::Bot ::Client . new do |config |
59
+ config . endpoint = 'https://example.com/api/v1'
60
+ end
61
+ expect ( client . endpoint ) . to eq 'https://example.com/api/v1'
62
+ expect ( client . blob_endpoint ) . to eq 'https://example.com/api/v1' # rewrited
63
+ end
64
+
42
65
it 'checks credentials on creating a client' do
43
66
channel_token = dummy_config [ :channel_token ]
44
67
client = Line ::Bot ::Client . new do |config |
You can’t perform that action at this time.
0 commit comments