11class EasyPost ::User < EasyPost ::Resource
2- def self . create ( params = { } , api_key = nil )
3- response = EasyPost . make_request ( :post , self . url , api_key , { self . class_name . to_sym => params } )
4- return EasyPost ::Util . convert_to_easypost_object ( response , api_key )
2+ def self . create ( params = { } , api_key = nil )
3+ response = EasyPost . make_request ( :post , url , api_key , { class_name . to_sym => params } )
4+ EasyPost ::Util . convert_to_easypost_object ( response , api_key )
55 end
66
77 def save
@@ -14,11 +14,11 @@ def save
1414 response = EasyPost . make_request ( :put , url , @api_key , wrapped_params )
1515 refresh_from ( response , api_key )
1616 end
17- return self
17+ self
1818 end
1919
2020 def self . retrieve_me
21- self . all
21+ all
2222 end
2323
2424 def self . all_api_keys
@@ -28,11 +28,11 @@ def self.all_api_keys
2828 def api_keys
2929 api_keys = EasyPost ::User . all_api_keys
3030
31- if api_keys . id == self . id
31+ if api_keys . id == id
3232 my_api_keys = api_keys . keys
3333 else
34- for child in api_keys . children
35- if child . id == self . id
34+ api_keys . children . each do | child |
35+ if child . id == id
3636 my_api_keys = child . keys
3737 break
3838 end
@@ -41,4 +41,16 @@ def api_keys
4141
4242 my_api_keys
4343 end
44+
45+ def update_brand ( **attrs )
46+ brand = EasyPost ::Brand . new
47+ data = { object : "Brand" , user_id : id , **attrs }
48+ # Add accessors manually because there's no API to retrieve a brand
49+ brand . add_accessors ( data . keys )
50+ # Assigning values with accessors defined above
51+ data . each do |key , val |
52+ brand . send ( "#{ key } =" , val )
53+ end
54+ brand . save
55+ end
4456end
0 commit comments