Skip to content

Commit

Permalink
Fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
kaibadash committed Apr 22, 2017
2 parents 76bff98 + 6cd5744 commit fc69be9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
26 changes: 13 additions & 13 deletions src/chatwork.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ class ChatworkStreaming extends EventEmitter

create: (name, adminIds, opts, callback) =>
params = []
params.push "name=#{name}"
params.push "members_admin_ids=#{adminIds.join ','}"
params.push "description=#{opts.desc}" if opts.desc?
params.push "name=#{encodeURIComponent name}"
params.push "members_admin_ids=#{encodeURIComponent adminIds.join ','}"
params.push "description=#{encodeURIComponent opts.desc}" if opts.desc?
params.push "icon_preset=#{opts.icon}" if opts.icon?
params.push "members_member_ids=#{opts.memberIds.join ','}" if opts.memberIds?
params.push "members_readonly_ids=#{opts.roIds.join ','}" if opts.roIds?
params.push "members_member_ids=#{encodeURIComponent opts.memberIds.join ','}" if opts.memberIds?
params.push "members_readonly_ids=#{encodeURIComponent opts.roIds.join ','}" if opts.roIds?
body = params.join '&'
@post "/rooms", body, callback

Expand All @@ -99,9 +99,9 @@ class ChatworkStreaming extends EventEmitter

update: (opts, callback) =>
params = []
params.push "description=#{opts.desc}" if opts.desc?
params.push "description=#{encodeURIComponent opts.desc}" if opts.desc?
params.push "icon_preset=#{opts.icon}" if opts.icon?
params.push "name=#{opts.name}" if opts.name?
params.push "name=#{encodeURIComponent opts.name}" if opts.name?
body = params.join '&'
@put "#{baseUrl}", body, callback

Expand All @@ -119,9 +119,9 @@ class ChatworkStreaming extends EventEmitter

update: (adminIds, opts, callback) =>
params = []
params.push "members_admin_ids=#{adminIds.join ','}"
params.push "members_member_ids=#{opts.memberIds.join ','}" if opts.memberIds?
params.push "members_readonly_ids=#{opts.roIds.join ','}" if opts.roIds?
params.push "members_admin_ids=#{encodeURIComponent adminIds.join ','}"
params.push "members_member_ids=#{encodeURIComponent opts.memberIds.join ','}" if opts.memberIds?
params.push "members_readonly_ids=#{encodeURIComponent opts.roIds.join ','}" if opts.roIds?
body = params.join '&'
@put "#{baseUrl}/members", body, callback

Expand All @@ -130,7 +130,7 @@ class ChatworkStreaming extends EventEmitter
@get "#{baseUrl}/messages", "", callback

create: (text, callback) =>
body = "body=#{text}"
body = "body=#{encodeURIComponent text}"
@post "#{baseUrl}/messages", body, callback

listen: =>
Expand Down Expand Up @@ -162,8 +162,8 @@ class ChatworkStreaming extends EventEmitter

create: (text, toIds, opts, callback) =>
params = []
params.push "body=#{text}"
params.push "to_ids=#{toIds.join ','}"
params.push "body=#{encodeURIComponent text}"
params.push "to_ids=#{encodeURIComponent toIds.join ','}"
params.push "limit=#{opts.limit}" if opts.limit?
body = params.join '&'
@post "#{baseUrl}/tasks", body, callback
Expand Down
34 changes: 17 additions & 17 deletions test/chatwork.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ describe 'ChatworkStreaming', ->
name = 'Website renewal project'
adminIds = [123, 542, 1001]
api.post('/v2/rooms').reply 200, (url, body) ->
body.should.be.equal "name=#{name}" \
+ "&members_admin_ids=#{adminIds.join ','}"
body.should.be.equal "name=#{encodeURIComponent name}" \
+ "&members_admin_ids=#{encodeURIComponent adminIds.join ','}"
done()
bot.Rooms().create name, adminIds, {}, null

Expand All @@ -187,12 +187,12 @@ describe 'ChatworkStreaming', ->
api.post('/v2/rooms').reply 200, (url, body) ->
params = Helper.parseBody body
params.should.be.deep.equal
description: opts.desc
description: encodeURIComponent opts.desc
icon_preset: opts.icon
members_admin_ids: adminIds.join ','
members_member_ids: opts.memberIds.join ','
members_readonly_ids: opts.roIds.join ','
name: name
members_admin_ids: encodeURIComponent adminIds.join ','
members_member_ids: encodeURIComponent opts.memberIds.join ','
members_readonly_ids: encodeURIComponent opts.roIds.join ','
name: encodeURIComponent name
done()
bot.Rooms().create name, adminIds, opts, null

Expand Down Expand Up @@ -232,9 +232,9 @@ describe 'ChatworkStreaming', ->
api.put(baseUrl).reply 200, (url, body) ->
params = Helper.parseBody body
params.should.be.deep.equal
description: opts.desc
description: encodeURIComponent opts.desc
icon_preset: opts.icon
name: opts.name
name: encodeURIComponent opts.name
done()
room.update opts, null

Expand Down Expand Up @@ -277,7 +277,7 @@ describe 'ChatworkStreaming', ->
it 'should update members when no opts', (done) ->
adminIds = [123, 542, 1001]
api.put("#{baseUrl}/members").reply 200, (url, body) ->
body.should.be.equal "members_admin_ids=#{adminIds.join ','}"
body.should.be.equal "members_admin_ids=#{encodeURIComponent adminIds.join ','}"
done()
room.Members().update adminIds, {}, null

Expand All @@ -290,9 +290,9 @@ describe 'ChatworkStreaming', ->
api.put("#{baseUrl}/members").reply 200, (url, body) ->
params = Helper.parseBody body
params.should.be.deep.equal
members_admin_ids: adminIds.join ','
members_member_ids: opts.memberIds.join ','
members_readonly_ids: opts.roIds.join ','
members_admin_ids: encodeURIComponent adminIds.join ','
members_member_ids: encodeURIComponent opts.memberIds.join ','
members_readonly_ids: encodeURIComponent opts.roIds.join ','
done()
room.Members().update adminIds, opts, null

Expand All @@ -308,7 +308,7 @@ describe 'ChatworkStreaming', ->
it 'should create a message', (done) ->
message = 'This is a test message'
api.post("#{baseUrl}/messages").reply 200, (url, body) ->
body.should.be.equal "body=#{message}"
body.should.be.equal "body=#{encodeURIComponent message}"
fixtures.room.messages.post

room.Messages().create message, (err, data) ->
Expand Down Expand Up @@ -371,7 +371,7 @@ describe 'ChatworkStreaming', ->
text = "Buy milk"
toIds = [1, 3, 6]
api.post("#{baseUrl}/tasks").reply 200, (url, body) ->
body.should.be.equal "body=#{text}&to_ids=#{toIds.join ','}"
body.should.be.equal "body=#{encodeURIComponent text}&to_ids=#{encodeURIComponent toIds.join ','}"
done()
room.Tasks().create text, toIds, {}, null

Expand All @@ -383,9 +383,9 @@ describe 'ChatworkStreaming', ->
api.post("#{baseUrl}/tasks").reply 200, (url, body) ->
params = Helper.parseBody body
params.should.be.deep.equal
body: text
body: encodeURIComponent text
limit: "#{opts.limit}"
to_ids: toIds.join ','
to_ids: encodeURIComponent toIds.join ','
done()
room.Tasks().create text, toIds, opts, null

Expand Down

0 comments on commit fc69be9

Please sign in to comment.